Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QLabel and zooming background by selecting a rectangle with the mouse
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QLabel and zooming background by selecting a rectangle with the mouse

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    i92guboj
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giordi
      wrote on last edited by
      #2

      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

      Coding is powaaaaa

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NicuPopescu
        wrote on last edited by
        #3

        start with the "Image Viewer Example":http://qt-project.org/doc/qt-4.8/widgets-imageviewer.html

        1 Reply Last reply
        0
        • I Offline
          I Offline
          i92guboj
          wrote on last edited by
          #4

          @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 :)

          1 Reply Last reply
          0
          • I Offline
            I Offline
            i92guboj
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved