Unsolved How do I add a qtablewidget in a qscrollarea to make it scrollable?
-
Hello great minds,
Please how do I add my qTableWidgets scrollable in a qScrollArea?
I want the qTableWidgets to be in the scrollarea but from the codes below, whenever I add the qTablewidget to the vbox1 layout, nothing displays on the window when I run the code.<> glayttab = QGridLayout() gboxtab = QGroupBox() gboxtab.setCheckable(True) vboxtab1 = QVBoxLayout() self.setLayout(glayttab) glayttab.addWidget(gboxtab) gboxtab.setLayout(vboxtab1) self.tab = QtWidgets.QTableWidget(self) vboxtab1.addWidget(self.tab) scroltab = QScrollArea() scroltab.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scroltab.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) scroltab.setWidgetResizable(True) scroltab.setWidget(gboxtab) scroltab.ensureVisible(1900, 1900) glayttab.addWidget(scroltab)`
-
QTableWidget
is a scroll area (the inheritance graph isQAbstractScrollArea
→QAbstractItemView
→QTableView
→QTableWidget
) so you don't need to insert it in a scroll area.
What is the result you are trying to get? -
Thanks for your feedback.
I see where I was making the mistake. I was using QMainWindow for the class, and didn't setCentral area. I have to change my class to QWidget. It works fine now