Occupy the full width and height of the screen with a QTableWidget

0

I am trying to occupy all the width and height of my window with a QTable Widget for this I have:

#Mi layout
vboxLayout = QtWidgets.QVBoxLayout(self)   
self.mainLayout = QtWidgets.QGridLayout()
vboxLayout.addLayout(self.mainLayout)
vboxLayout.addStretch() 

#Tabla
self.table = QtWidgets.QTableView()
self.table.setObjectName("table")    
self.tableWidget = QtWidgets.QTableWidget()
self.tableWidget.setObjectName("tableWidget")    

#Layout
self.mainLayout.addWidget(self.tableWidget, 6, 0, 5, 7)

And what you see on the screen:

    
asked by Adriana_0_0 14.08.2018 в 09:13
source

1 answer

0

If you want the QTableWidget to be expanded throughout the window and this within the QGridLayout you should not use addStretch (), in addition to indicating the row, column, rowSpan and columnSpan:

import sys
from PyQt5 import QtWidgets


class Widget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        #Mi layout
        vboxLayout = QtWidgets.QVBoxLayout(self)   
        self.mainLayout = QtWidgets.QGridLayout()
        vboxLayout.addLayout(self.mainLayout)

        #Tabla
        self.tableWidget = QtWidgets.QTableWidget()
        self.tableWidget.setObjectName("tableWidget")    

        #Layout
        self.mainLayout.addWidget(self.tableWidget)



if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = Widget()
    w.show()
    sys.exit(app.exec_())
    
answered by 14.08.2018 / 11:47
source