PDA

View Full Version : Nothing appears in QScrollArea



space_otter
8th November 2011, 06:11
The following code appears in a custom dialog constructor:


layout = QVBoxLayout()

watcher = DWatcher(None, DProperties({'value':settings}))

scroller = QScrollArea()
scroller.setWidget(watcher)
layout.addWidget(scroller)

layout2 = QHBoxLayout()
layout2.addWidget(QPushButton('OK'))
layout2.addWidget(QPushButton('Cancel'))
layout.addItem(layout2)

self.setLayout(layout)
When the dialog appears, there is nothing in the scrollarea. DWatcher has a layout after its constructor exits. If I simply add the DWatcher, it works just like it's supposed to, but it can be really big so I want it in a scrollarea. Any ideas how this might happen?

Spitfire
16th November 2011, 13:28
From documentation:
If the scroll area is visible when the widget is added, you must show() it explicitly.
Note that You must add the layout of widget before you call this function (setWidget()); if you add it later, the widget will not be visible - regardless of when you show() the scroll area. In this case, you can also not show() the widget later
Maybe the second line is your reason?