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. GraphicsView doesn't center on the contents upone setting the scene

GraphicsView doesn't center on the contents upone setting the scene

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 470 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
    Shpacuh
    wrote on last edited by
    #1

    My program behaves visually very similar to that 40.000 chips example program found in the qt creator: It creates many rectangle QGraphicItems, adds them to a scene and sets the scene to my QGraphicsview subclass. It used to set the scene so that the contents were centered, but after some feature it started placing the graphicsView at the top left corner of the contents.
    The real problem is that if the user tries to zoom out before he did any scrolling the view jumps to the center of the contents and then does the zooming, which is confusing to a user because seemingly all the changes to the tiles he did (one in the top left corner) seemingly vanish until they notice that the view has jumped towards the middle of the contents.

    Is there something I'm forgetting to set upon initializing the graphicsview so that it doesn't start centered?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Shpacuh
      wrote on last edited by
      #2

      Found it. This behavior is somehow controlled by the resizeAnchor property. It appears that when the GraphicsView is placed in the program through the UI designer the property in question is set to noAnchor. Setting it to either AnchorUnderMouse or AnchorViewCenter completely fixes the problem.

      1 Reply Last reply
      1

      • Login

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