resizeable rubber band with QSizeGrip
-
Hi - I'm using Qt 5.14 on Win10 x64
Trying to implement a resizeable "rubber band" for ROI selection over an image, using what I found here as the accepted answer on StackOverflow:
My code is exactly as in the example.
Generally it works as I expect. However, in the above example, the size grip in the upper left is pointing up and to the left (and can presumably adjust the ROI up and to the left) and the one in the lower right is pointing down and to the right and can adjust the ROI down/right.
My lower right QSizeGrip works and looks as expected and I can use it to expand my ROI down/right as I'd expect. But the one in the upper left is not painted pointing up/left like it is in the stackoverflow example, it looks the same as the one in the lower right. Dragging it left/right adjusts my ROI as expected, but dragging it up/down is exactly the same behavior as dragging the lower right sizegrip, where the upper left corner of the ROI is anchored, rather than actually resizing it in that direction.
I realize the stack overflow example is quite old and against an older version of Qt, but does anybody know how I can make it so the two drag handles can expand the ROI in both directions as expected?
Thanks! -
Hi,
Can you provide a minimal compilable example that shows the behaviour you have ? There might be something unrelated to the stack overflow code happening.
-
That's a good news.
Then I would disable all widgets that are not related to your rubber band and gradually add them back until things get wrong.
-
Yah I started looking at how I was setting it up and controlling it - the GUI interaction of this particular app positions the rubber band automatically at previously user-defined positions. I was calling setGeometry on it with a QRect whose coordinates were reversed. (interestingly to no visual detriment.) Now that I've changed that, the QSizeGrip handles do function as expected, I can resize up/left just as well as down/right.. The upper left arrow itself is not pointing the correct direction (up/left) but at least now it's behaving as expected.
-
Then there must be one last glitch hiding.
-
There's a method in the private implementation of the class that determines that based on the position of the grip.
-
Hi,
Can you provide a minimal compilable example that shows the behaviour you have ? There might be something unrelated to the stack overflow code happening.