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. [Solved] Scroll QGraphicsView when sceneRect resized
Forum Updated to NodeBB v4.3 + New Features

[Solved] Scroll QGraphicsView when sceneRect resized

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

    Hi I am trying to use the Graphics View Framework to implement a diagram editor. I would like to have a "canvas" area with resize handles. I want this to be centered in the QGraphicsView with a constant margin around it.

    !http://s22.postimg.org/fhs8y5q0h/Screen_Shot_2014_04_20_at_00_37_02.png(Canvas area)!

    For this I've used a custom QGraphicsRectItem class and also added the handles to resize it which seems to work nicely. This is updating the sceneRect to the rectItems size plus the margin. The problem is when I drag one of the handles and the view expands, the view stays centered at the same position when I would like it to scroll with the scrollbars.

    !http://s22.postimg.org/5vyohuyup/Screen_Shot_2014_04_20_at_00_37_19.png(Canvas area not scrolling)!

    Any idea on how I could achieve this behaviour?

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi and welcome to Devnet,

      "EnsureVisible":http://qt-project.org/doc/qt-5/qgraphicsview.html#ensureVisible

      Might be what you need.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobycronin
        wrote on last edited by
        #3

        Thank you! Calling ensureVisible on the handle gets the intended behaviour.

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          You are welcome.

          Please edit the title of your first post and prepend [solved] to it. This informs others about the status of your question.

          Qt Certified Specialist
          www.edalsolutions.be

          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