[SOLVED] QLabel and zooming background by selecting a rectangle with the mouse
-
Hi, again. :)
I "was doing":http://qt-project.org/forums/viewthread/32918/ a hover-aware zoom-on-hover Qlabel. That works ok, but now someone decided that it would be better if the user could just select a region on the QLabel with the mouse so that it would be zoomed on mouse-release event.
I think I can handle the events by now (won't say it too loud, just in case :lol:) but I have no idea on how to go about the selection rectangle.
It would be something like what you can find in most GUI file managers, where you click-hold-move-release to select some files. The aspect of the rectangle is not too important...
Do I need to draw some widget on top of the QLabel to achieve this or is there a saner way to do it? I really don't even know what to search for this time so any hint will be appreciated :)
Thank you!
-
Just guessing... you might have to use an eventFilter on your main window in order to catch the mouse press over the main window , then wiith that you can easily track the press and release of the mouse and get the area that has been drag-selected
-
start with the "Image Viewer Example":http://qt-project.org/doc/qt-4.8/widgets-imageviewer.html
-
@giordi, this works well. I was able to capture the right events at the right place. Now all is left is to do the maths and work on the function to readjust the image in the QLabel.
@NicuPopescu, thanks for the suggestion. I had already read that, but for some reason I decided to implement this with QLabel, it has proben to be quite simple indeed. I am loving Qt more and more :)
-
A bit offtopic, but... how would I go about painting the ribbon? I've been searching around but it's difficult to find something relevant. I guess it would be more straightforward with a QGraphicView, but with can I achieve that with QLabel?