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. Zooming in paintevent
Qt 6.11 is out! See what's new in the release blog

Zooming in paintevent

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • S Offline
    S Offline
    sidharth
    wrote on last edited by
    #1

    i am new to qt.please help me out.

    i have drawn one gui in paintevent on mainwindow.now i want to zoom the gui such that my gui have 4 arrow buttons and i can see my zooming in any direction using arrow buttons.
    please tell me how can i do it by giving me small example by drawing rectangle and then zooming it using arrow buttons..

    any help will be appreciated.
    thankyou.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      There isn't a trivial solution to what you want to to.

      What do you mean with "i have drawn one gui in paintevent on mainwindow"? Didn't you "set a central widget":http://qt-project.org/doc/qt-4.8/qmainwindow.html#setCentralWidget of the mainwindow? Did you override QMainWindow's paintEvent handler?

      For the zooming rectangle you can check out "QRubberBand":http://qt-project.org/doc/qt-4.8/qrubberband.html class.

      I also think you would be better off by using QGraphicsView as your canvas and zoom in there. Since it provides you with all you need (incl. event position translation, ... )

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sidharth
        wrote on last edited by
        #3

        thanks for your suggestion and for your concern.

        i mean that i have created 4 widgets on ui on mainwindow by drag and drop and i have drawn some circles on every widget .now i want to zoom the figure which i have drawn on different widgets.and i want some arrow buttons on which if i click,i can see my scrolling in that direction....
        please help me in doing that as i have stuck in this portion of my project.
        thankyou

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          and you want to zoom every widget's circle individually? Or zoom them altogether at once?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sidharth
            wrote on last edited by
            #5

            i want to zoom them altogether...please help me sir... :(send me a code which is as simple as possible.
            i have drawn my figures using paintevent....

            thankyou

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              There is no simple/short code example, but there are plenty of tutorials about "QGraphicsView":http://qt-project.org/doc/qt-4.8/qgraphicsview.html on the web.
              All you need to to is to "add your circles":http://qt-project.org/doc/qt-4.8/qgraphicsscene.html#addEllipse to the QGraphicsScene. For simplification you can see the QGraphicsItems as QWidgets in your canvas.

              Finally you "zoom":http://qt-project.org/doc/qt-4.8/qgraphicsview.html#scale your QGraphicsView (calculate the zooming-value from the ratio of QRubberBand rect to the viewport rect).

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              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