Putting a scroll bar into a grid-placed widget
-
I have a grid layout with Qlabels . Because there any many rows...around 150 rows with labels, I am trying to put a scroll bar on the right. But it does not work although I tried many configurations from googling search. Can you help?
I am using this code (source: https://www.geeksforgeeks.org/pyqt5-qlistwidget-adding-extra-scroll-bar-to-it/):
win = QWidget() mygrid=QGridLayout() # scroll bar scroll_bar = QScrollBar(self) # setting style sheet to the scroll bar scroll_bar.setStyleSheet("background : lightgreen;") # adding extra scroll bar to it mygrid.addScrollBarWidget(scroll_bar, Qt.AlignLeft)
-
@john_hobbyist
You can't add that to a layout. My expectation, I think, would be to use aQScrollArea
around aQWidget
containing yourQGridLayout
.[UPDATE I see the latest new post while I was writing this, https://forum.qt.io/topic/138690/layout-for-qscrollarea-to-expand-horizontally-vertically, uses just this approach.]
-
Thanks! However, I have no idea pf C/C++... :-)
-
@john_hobbyist
I merely mentioned it happened to be a post using that approach which had just been made, suggesting that was the way to go. If you like, forget I even mentioned it.If you want to wait till any example is in Python that is up to you.
-
@JonB said in Putting a scroll bar into a grid-placed widget:
@john_hobbyist
I merely mentioned it happened to be a post using that approach which had just been made, suggesting that was the way to go. If you like, forget I even mentioned it.If you want to wait till any example is in Python that is up to you.
Thanks a lot!! No worries!! I am studying your post... ;-)