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. QGraphicsScene fit scene rect into current view size without changing its position
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene fit scene rect into current view size without changing its position

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

    I am trying to fit the scene rect, into current widget size, to prevent from showing unnecessary items and scroll bars.

    Unlucky, when i change the scene rect size, the view change it's position, which change the items that are shown, and i can't figure it out how to resize the rect, without changing the view and what is displayed.

    Hiding the scrollbars doesn't help, since isVisible() (item) still return true. The performance looks like it's worse when the scene rect is big, and there are few more problems. I tried to use setSceneRect(), but i wasn't able to figure out any way, to change the size, and set the position, so it will look like it wasn't touched. I tried also sceneRect().adjust(), but still the position isn't the previous one.

    Setting a const size doesn't help, because i has to be able to pan the scene, in order to explore other items. So since pan doesn't work once the scene reach the border, i resize the scene to be able to pan to the items, then i would like to resize the scene, so the invisible items will be hidden.

    277ddf57-e980-4254-a14e-fc5619e9c2a6-obraz.png

    A 1 Reply Last reply
    0
    • L Loc888

      I am trying to fit the scene rect, into current widget size, to prevent from showing unnecessary items and scroll bars.

      Unlucky, when i change the scene rect size, the view change it's position, which change the items that are shown, and i can't figure it out how to resize the rect, without changing the view and what is displayed.

      Hiding the scrollbars doesn't help, since isVisible() (item) still return true. The performance looks like it's worse when the scene rect is big, and there are few more problems. I tried to use setSceneRect(), but i wasn't able to figure out any way, to change the size, and set the position, so it will look like it wasn't touched. I tried also sceneRect().adjust(), but still the position isn't the previous one.

      Setting a const size doesn't help, because i has to be able to pan the scene, in order to explore other items. So since pan doesn't work once the scene reach the border, i resize the scene to be able to pan to the items, then i would like to resize the scene, so the invisible items will be hidden.

      277ddf57-e980-4254-a14e-fc5619e9c2a6-obraz.png

      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @Loc888 QGraphicsView::fitInView?

      L 1 Reply Last reply
      2
      • A Asperamanca

        @Loc888 QGraphicsView::fitInView?

        L Offline
        L Offline
        Loc888
        wrote on last edited by
        #3

        @Asperamanca Doesn't work. I need to get rid of unnecessary scene size, then return the view/scene to it's LAST position, so the view will look like it wasn't changed at all, execept the size to match the current view. FitScene scale it to fit the contents, which is not what i need to do.

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

          You don't really explain what you need and why. You write about "changing the scene rect", but you don't explain why you need to change the scene rect at all. You write that you want to "prevent showing unnecessary items and scrollbars", but you can hide the scroll bars, and items outside the view won't be visible to the user, so what's 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