PDA

View Full Version : QScrollArea and Painting issue



myfifth
20th January 2011, 09:00
I've built my own QScrollArea-based widget, it will have or not have a scrollbar.
If it has a scrollbar, a content widget will be added and painting would be happened on content widget.
If it doesn't have a scrollbar, it would work as a simple frame widget.

However, I found that when there was no scrollbar, I can't paint anything on it in overridden paintEvent(). The paint event was received and some paintings was done, but no effect.

I'm wondering it's that QSrcollArea disabled painting by default.
I'm looking for someone could help me confirm it.
Thx.

wysota
20th January 2011, 11:37
Please provide a minimal compilable example reproducing the problem.

nish
20th January 2011, 11:52
also play around with viewport() and viewportwidget, and have your paintevent on the relevant widget

myfifth
21st January 2011, 02:48
Please provide a minimal compilable example reproducing the problem.

Pls check out attachment. I quickly built a demo, but weird, both paintEvent never got called.

5805


also play around with viewport() and viewportwidget, and have your paintevent on the relevant widget

I just learned about viewport() which said QScrollArea will assign a new QWidget anyway for viewport if I missed set one, I'm afraid that if it's quite appropriate for my initial purpose of making it being a normal frame widget if there's no scrollbar.

nish
21st January 2011, 08:21
consider using a stackwidget for displaying your two views. set one to QFrame and another to QScrollArea