Do you do anything with the viewport of the scrollarea?
Do you do anything with the viewport of the scrollarea?
no ,if i substitue viewport() with this then i get "QPainter::begin: Widget painting can only begin as a result of a paintEvent" this message.
But you had to setup the viewport somehow in the first place... otherwise scrollbars wouldn't work. Do they?
i have not tested it yet,but now i solved the problem.Instead of calling update(), calling viewport()->update() works fine.
yes thats true .i only want to show a pixmap on the viewport ,how to get the scrollbars .if i need the scrollbars should i have to paint on the viewport widget.But you had to setup the viewport somehow in the first place... otherwise scrollbars wouldn't work. Do they?
If you don't want the scrollbars, why do you use QAbstractScrollArea instead of QWidget?
of course i want scrollbars,i am making a image viewer with scrollbars, if i need the scrollbars should i have to paint on the viewport widget.
So why not put a QLabel inside QScrollArea and forget about the whole problem?
As for the current situation scrollbars will only appear if you declare the viewport size larger than the scrollarea size. Currently you didn't declare anything so the viewport size is practically undetermined. Unless you implement scrollbar handling yourself (setting the sizes and handling moving them) you won't be able to use them.
So why not put a QLabel inside QScrollArea and forget about the whole problem?
As for the current situation scrollbars will only appear if you declare the viewport size larger than the scrollarea size. Currently you didn't declare anything so the viewport size is practically undetermined. Unless you implement scrollbar handling yourself (setting the sizes and handling moving them) you won't be able to use them.
if i need to have zoom and image moving features(through wheel event and mouse move event) ,should i have to reimplement the QLabel.So why not put a QLabel inside QScrollArea and forget about the whole problem?
No, you just set the zoomed pixmap to the label. Panning should work out of the box.
i am following the same .I need rubberband zooming .Is it possible with QScrollArea.So why not put a QLabel inside QScrollArea and forget about the whole problem?
Yes, of course. Use QRubberBand and calculate the zoom rectangle based on the position of the viewport.
Bookmarks