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. Example of Zooming QPixmap Within a Frame
Forum Updated to NodeBB v4.3 + New Features

Example of Zooming QPixmap Within a Frame

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 483 Views
  • 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.
  • K Offline
    K Offline
    kendavistoo
    wrote on last edited by
    #1

    I have written an example which should be useful. An jpg image is loaded from a resource file. It is converted to a pixmap. QPainter is used to draw a viewport of the image in a QFrame. The mouse wheel is used to vary the size of the viewport rectangle. This zooms the image in the frame. The pixmap can moved under the viewport by dragging with the wheel button (Qt::MidButton).
    A second frame displays the entire image, and the viewport is represented in this second frame by an overlying red rectangle. This rectangle can be translated with the WASD keys or the arrow keys. The red rectangle can be dragged with the wheel button.
    Signals and slots are used to communicate between the two frames. My coding usually is kind of clunky. For example, I call update() within paintEvent() to create a loop - this probably is not a good idea. The project is available on GitHub as Qt-Image_Zoom_Example at https://github.com/kendavistoo. I hope this helps somebody.

    1 Reply Last reply
    2

    • Login

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