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 doesn't allow to scroll to added content
Forum Updated to NodeBB v4.3 + New Features

QGraphicsView doesn't allow to scroll to added content

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 342 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.
  • GilboonetG Offline
    GilboonetG Offline
    Gilboonet
    wrote on last edited by Gilboonet
    #1

    My application creates shapes and add them to the QGraphicsView that has
    verticalScrollBarPolicy ScrollBarAlwaysOn
    horizontalScrollBarPolicy ScrollBarAlwaysOn
    sizeAdjustPolicy AdjustToContents

    but I cannot scroll past the size of the sceneRect. To see my shapes I need to zoom out (using scale() on the graphicsView widget).

    Do I need to change the sceneRect at runtime after I added all my shapes ?

    I tried to change the sceneRect to a QRectF having the size needed, or even a null QRectF, but nothing changes.
    deplUISCroll1.png deplUISCroll2.png

    JonBJ 1 Reply Last reply
    0
    • JonBJ JonB

      @Gilboonet said in QGraphicsView doesn't allow to scroll to added content:

      but I cannot scroll past the size of the sceneRect

      Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place QGpahicsItems on it. Just confirm how you add these "shapes". A QGrphicsView is a view onto this, so why do you want to scroll outside the scene rectangle?

      If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.

      QGraphicsView also has its own scene rectangle, the area of the scene it covers. By default it returns the QGraphicsScene's scene rectangle. You can alter it for the view if you want that.

      GilboonetG Offline
      GilboonetG Offline
      Gilboonet
      wrote on last edited by
      #3

      @JonB Thank you, what you said helped me find what I was doing wrong : I did set the GraphicsView's sceneRect width and length properties. Setting them to 0 make it work as I needed. The screenshots are what I had as view, on the first one the scale as 100% and there are GraphicsItems to the left but no scrollbars. The second screenshot is at scale 30%.

      1 Reply Last reply
      0
      • GilboonetG Gilboonet

        My application creates shapes and add them to the QGraphicsView that has
        verticalScrollBarPolicy ScrollBarAlwaysOn
        horizontalScrollBarPolicy ScrollBarAlwaysOn
        sizeAdjustPolicy AdjustToContents

        but I cannot scroll past the size of the sceneRect. To see my shapes I need to zoom out (using scale() on the graphicsView widget).

        Do I need to change the sceneRect at runtime after I added all my shapes ?

        I tried to change the sceneRect to a QRectF having the size needed, or even a null QRectF, but nothing changes.
        deplUISCroll1.png deplUISCroll2.png

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @Gilboonet said in QGraphicsView doesn't allow to scroll to added content:

        but I cannot scroll past the size of the sceneRect

        Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place QGpahicsItems on it. Just confirm how you add these "shapes". A QGrphicsView is a view onto this, so why do you want to scroll outside the scene rectangle?

        If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.

        QGraphicsView also has its own scene rectangle, the area of the scene it covers. By default it returns the QGraphicsScene's scene rectangle. You can alter it for the view if you want that.

        GilboonetG 1 Reply Last reply
        1
        • JonBJ JonB

          @Gilboonet said in QGraphicsView doesn't allow to scroll to added content:

          but I cannot scroll past the size of the sceneRect

          Sorry, I don't understand what you mean here, nor what your screenshots illustrate. The scene rectangle is the whole scene. You can set it if you want, but if you leave it null as it is by default it auto-grows as you place QGpahicsItems on it. Just confirm how you add these "shapes". A QGrphicsView is a view onto this, so why do you want to scroll outside the scene rectangle?

          If you want your scene to be bigger than the bounding rectangle of all the items on it, then set it larger yourself.

          QGraphicsView also has its own scene rectangle, the area of the scene it covers. By default it returns the QGraphicsScene's scene rectangle. You can alter it for the view if you want that.

          GilboonetG Offline
          GilboonetG Offline
          Gilboonet
          wrote on last edited by
          #3

          @JonB Thank you, what you said helped me find what I was doing wrong : I did set the GraphicsView's sceneRect width and length properties. Setting them to 0 make it work as I needed. The screenshots are what I had as view, on the first one the scale as 100% and there are GraphicsItems to the left but no scrollbars. The second screenshot is at scale 30%.

          1 Reply Last reply
          0
          • GilboonetG Gilboonet has marked this topic as solved on

          • Login

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