Antonio
Antonio

Reputation: 602

Pyqt qtablewidget using all window space

I'm trying to make a simple UI with: a qtablewidget, a pushbutton and a status bar. But the table uses all window space, so I just can't see the pushbutton... Can anyone please help me? I can't see what I'm doing wrong.

class Example(QtGui.QMainWindow):
    def __init__(self):

        super(Example, self).__init__()

        table = QtGui.QTableWidget(q, 6)
        table.setGeometry(QtCore.QRect(0, 0, 1021, 461))
        table.setDragEnabled(True)
        table.setAlternatingRowColors(True)
        table.setCornerButtonEnabled(True)
        table.setSortingEnabled(True)
        table.verticalHeader().setSortIndicatorShown(True)

        self.setCentralWidget(table)

        table.setColumnWidth(0, 45)
        table.setColumnWidth(1, 100)
        table.setColumnWidth(2, 70)
        table.setColumnWidth(3, 65)
        table.setColumnWidth(4, 650)
        table.setColumnWidth(5, 90)

        b_save = QtGui.QPushButton()
        b_save.setGeometry(QtCore.QRect(0, 469, 101, 23))
        b_save.setObjectName(_fromUtf8("b_save"))

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    if Login().exec_() == QtGui.QDialog.Accepted:
        window = Example()
        window.setWindowTitle('Tarefas')
        window.resize(1070, 561)
        window.show()
        sys.exit(app.exec_())

Upvotes: 0

Views: 993

Answers (1)

Dimitry Ernot
Dimitry Ernot

Reputation: 6584

You have setted your table as central widget. So, it wil be placed and resized by the main layout. You should place your button and table with a layout in another widget and set that widget as central widget.

Upvotes: 1

Related Questions