title: How to put a table at the center of the window (Set table position)
body: <p>So, I'm working on an application and I'm using QTableWidget to generate a table. I want to put the table at the center of the window but I can't find a way to do this, it takes way too much space and its stucked at the top left of the window. I'm putting the table and a button in a QVBoxLayout, there's some blank space after the table (at the bottom and the right) and then the button, far away from the table. </p>
  
  <p>Thats how its looking like</p>
  
  <p><img src="https://i.stack.imgur.com/aWnYa.png" alt=""></p>
  
  <p>And thats how i want it to be</p>
  
  <p><img src="https://i.stack.imgur.com/D9pxK.png" alt=""></p>
  
  <p>Right now my code is like this:</p>
  
  <pre><code>from PyQt5.QtWidgets import  QHeaderView, QPushButton, QMainWindow, QApplication, QMenuBar, QAction, QFileDialog, QWidget, QTableView, QVBoxLayout, QHBoxLayout, QTableWidget, QTableWidgetItem
  from PyQt5.QtCore import QAbstractTableModel, Qt
  from PyQt5 import QtGui
  import sys
  
  class MyApp(QMainWindow):
      def __init__(self):
          super().__init__()
  
          self.createWindow()
  
          self.show()
  
  
      def createWindow(self):
          self.setWindowTitle('Pós Graduação')
          self.setWindowIcon(QtGui.QIcon('icon.ico'))
          self.setGeometry(300, 100, 700, 600)
  
          self.table_widget = TableWidget(self)
          self.setCentralWidget(self.table_widget)
  
  
  class TableWidget(QWidget):
  
      def __init__(self, parent):        
          super(TableWidget, self).__init__(parent)
          self.layout = QVBoxLayout(self)
          self.creatingTable(parent)
          #self.setLayout(self.layout)
  
  
      def creatingTable(self, parent):
  
          tableWidget = QTableWidget()
  
  
          tableWidget.setRowCount(6)
          tableWidget.setColumnCount(4)
  
          tableWidget.horizontalHeader().setVisible(False)
          tableWidget.verticalHeader().setVisible(False)
  
          header = tableWidget.horizontalHeader()       
          header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
          header.setSectionResizeMode(3, QHeaderView.ResizeToContents)
  
          self.layout.addWidget(tableWidget)
          self.button1 = QPushButton("Button 1")
          self.layout.addWidget(self.button1)
          self.setLayout(self.layout)
  
  
  if __name__ == '__main__':
      App = QApplication(sys.argv)
      App.setStyle('Fusion')
      window = MyApp()
      sys.exit(App.exec())
  </code></pre>