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. Focus QGraphicsview(scene?) on a certain object

Focus QGraphicsview(scene?) on a certain object

Scheduled Pinned Locked Moved General and Desktop
qgraphicssceneqgraphicsviewqgraphicsitem
3 Posts 3 Posters 1.8k 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.
  • D Offline
    D Offline
    delanyinspiron6400
    wrote on last edited by
    #1

    Hey guys,

    how do I focus a QGraphicsview on a specific item, if there are loads of items in a view?

    I tried "QGraphicsView::ensurevisible", "QGraphics::centerOn", but they don't seem to work and I can't figure out why?

    About my scenario, I'm constructing a visual representation of a stack layout, therefore I add loads of QGraphicsitems into
    the scene within the Graphicsview, and I'd like to focus on the most recently added item at each step? So the layout is: QGraphicsscene is set in QGraphicsview and items are added to the scene.
    Could it be, that I have to focus my scene, rather than my Graphicsview??

    Thanks to you all! :)

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

      Both ensureVisible and centerOn will only scroll, not zoom. If you want to zoom as well, use fitInView.

      Also, if your item is hidden behind other items, it won't be visible in any case.

      1 Reply Last reply
      1
      • W Offline
        W Offline
        Walux
        wrote on last edited by Walux
        #3

        Hey guys , i have the same problem , and the trick didn't solve it , did anyone solve it ?
        If so , can you share it , and save me hours of searching ?

        Nice regards :)

        Taking things from beginning to end : That's my entertainment !

        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