PDA

View Full Version : QScrollArea that only scrolls vertically



stephelton
13th January 2013, 00:40
I need a QScrollArea that only scrolls vetically. Horizontally, it should behave like a normal widget.

I've seen this thread here: http://qt-project.org/forums/viewthread/13728

However, the solution proposed there subclasses QScrollArea and manages the widget internally (it calls setWidget() in its constructor). I need something where the setWidget() can be called at a later time. The problem with this approach is that it sets an event filter on the widget, but if that can't be done in the constructor, I don't see where else a subclass can get access to the widget to install the filter.

Additionally, the size of the widget may change dynamically.

Any ideas?

wysota
13th January 2013, 12:48
I think it can still be done. One way is to provide a separate call for installing the event filter on the subwidget. Another isbproviding a separate call for setting the subwidget. Yet another is to monitor the scroll area for children additions and when the subwidget appears, set the event filter.