Issues with QScrollArea and custom widget
-
Hi,
Might be a silly question but how are you handling UGfxDisplay ?
-
@kshegunov said in Issues with QScrollArea and custom widget:
Well, something moved at least. Can you get the paint rects you get when zoomin in/out and when you scroll up/down/left/right along with the image rects and dump them all into a file?
Sure, I'll get that done.
@SGaist said in Issues with QScrollArea and custom widget:
Might be a silly question but how are you handling UGfxDisplay ?
I'm sorry, I don't understand what handling means in this context. Can you be more specific?
-
Are you calling something like
_centralScrollArea->setWidget(_myGDisplay);
?Then, are you sure that you should handle the scaling in
GDisplay
?When zooming, what about having something like
_myGDisplay->resize(_scale * _sourceSize);
So you only handle painting in that widget. -
@kshegunov said in Issues with QScrollArea and custom widget:
Well, something moved at least. Can you get the paint rects you get when zoomin in/out and when you scroll up/down/left/right along with the image rects and dump them all into a file?
Here you go: http://paste.ugfx.io/show/a5113bcc08
@SGaist said in Issues with QScrollArea and custom widget:
Are you calling something like _centralScrollArea->setWidget(_myGDisplay); ?
Yep, that's what I am doing.
@SGaist said in Issues with QScrollArea and custom widget:
When zooming, what about having something like _myGDisplay->resize(_scale * _sourceSize); So you only handle painting in that widget.
In my opinion that won't work as it will not scale up the contents inside of my
UGfxDisplay
. Keep in mind that theQPixmap
I draw in myUGfxDisplay::paintEvent()
is the content of a virtual display. That virtual display has a given size (width and height) in pixels. When zooming in I need to scale up everything. I don't display more of the widget, I just display the same content bigger. -
Have you noticed your image doesn't grow (or shrink)?
-
The image is not supposed to grow. The image represents the contents of the virtual display. It will always have the same amount of pixels no matter how much I zoom into the
UGfxDisplay
widget. My virtual display does not grow by zooming into it :p -
But why are you
redrawingreinitializing it at each paint event then? It got me confused, now I believe I know what you want. Should be something like this (I *think*):painter.drawImage(event->rect(), img, event->rect() / _scale);
PS. Or not. I need to think.
PS. After thinking:QRect paintRect = event->rect(); QRect sourceRect(paintRect.topLeft() / _scale, paintRect.size() / _scale); painter.drawImage(paintRect, img, sourceRect);
-
Wooo, I love you \o/ (still, not again, don't worry honey)
This is with your "After thinking" code: https://www.screencast.com/t/cEAa2z4Zd
In retrospect this seems somewhat obvious...
-
@Joel-Bodenmann said in Issues with QScrollArea and custom widget:
Wooo, I love you
Nice! Love and world peace and such things. ;)
In retrospect this seems somewhat obvious...
Yes, quantum mechanics also seems rather obvious to me ... after a few people thought and invented it. ;)
-
@kshegunov said in Issues with QScrollArea and custom widget:
Yes, quantum mechanics also seems rather obvious to me ... after a few people thought and invented it. ;)
invented? ;)
Too bad those people didn't teach you how to write nice code though :pThank you for your help guys, much appreciated!
-
@Joel-Bodenmann said in Issues with QScrollArea and custom widget:
Too bad those people didn't teach you how to write nice code though :p
This is all a fault of my own, sadly, but hey life's not all roses ... :)
Thank you for your help guys, much appreciated!
You are welcome. Now go and make us proud! ;D