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. QGraphicsView scale: can scale down with negative numbers or up with positive numbers but need it to roll round (big, big, big, back to start, big, bi
Forum Updated to NodeBB v4.3 + New Features

QGraphicsView scale: can scale down with negative numbers or up with positive numbers but need it to roll round (big, big, big, back to start, big, bi

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k 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.
  • D Offline
    D Offline
    Dolphin
    wrote on last edited by
    #1

    I have solved this using
    graphicsView->fitInView(m_scene.sceneRect());
    but thought I would post anyway in case it helps anyone else............

    I have a QGraphicsView which I am using the scale the content of the screen but (to match spec) I need the 'zoom' to be with a single key (rather than one for up and one for down). The screen should zoom from 'normal' in to a defined maximum then start from 'normal' again.

    If I use positive scale values I get the required zoom in. If I use negative scale values I get a zoom out. If I try to wrap around the positive numbers work fine but the negative numbers (instead of zooming out) turn the image UPSIDE DOWN!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Just create a new [[doc:QTransform]] based on the required zoom level, and set that on the view, instead of calling scale() directly. That way, you won't be modifying the existing zoom, but just setting a new value. All you need to do is create your range of accepted values, and choose the next one.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dolphin
        wrote on last edited by
        #3

        Even better thanks - any way of simply scaling a QPushButton (outside of a QGraphicsView)? I may have to do the scaling manually since everything has to stay on the screen - seems a bit over the top to have to change the button, icon and font size.

        Learning, learning, learning..........

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Nope. In QML, this would be trivial, but in the widget world these kinds of scenario's were not taken into account.

          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