Define several vBoxLayout within the same window

0

I have defined a vBoxLayout so that the upper elements of the window remain in the upper zone. Now, I have created a new vBoxLayout (without success) so that the table occupies the entire height of the window and there is no space left:

The code is as follows:

def Tabla(self):

vboxLayout = QtWidgets.QVBoxLayout(self)

#Boton de exportar a excel
toolButton = QtWidgets.QToolButton()
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(os.getcwd()+"\images\excel_tras.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)

toolButton.setIcon(icon1)
toolButton.setObjectName("toolButton")
toolButton.clicked.connect(lambda i: exportar(self))

#Tabla
table = QtWidgets.QTableView()
table.setObjectName("table")

tableWidget = QtWidgets.QTableWidget()
tableWidget.setObjectName("tableWidget")
tableWidget.setColumnCount(len(self.columnas))
tableWidget.setRowCount(len(self.listaDatos))
tableWidget.setSortingEnabled(True)
tableWidget.setSelectionBehavior(QTableView.SelectRows)

#Colocamos la cabecera
tableWidget.setHorizontalHeaderLabels(self.columnas)
header_view = tableWidget.horizontalHeader()
header_view.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

#Layout
mainLayout = QtWidgets.QGridLayout()
mainLayout.addWidget(tableWidget, 7, 0, 5, 7)
mainLayout.addWidget(toolButton, 6, 5, 1, 1, QtCore.Qt.AlignRight)

vboxLayout.addLayout(mainLayout)
vboxLayout.addStretch()

return tableWidget
    
asked by Adriana_0_0 21.08.2018 в 14:49
source

0 answers