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. Difference between QGraphicsView::sceneRect and QGraphicsScene::sceneRect?

Difference between QGraphicsView::sceneRect and QGraphicsScene::sceneRect?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 803 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on 3 Oct 2019, 14:30 last edited by
    #1

    The documentation is clear that QGraphicsView::sceneRect determines the extent of the scrollable area of the view, and that if this property is not explicitly set on the QGV then it is pulled from QGraphicsScene, and if this is not explicitly set then QGS::sceneRect returns the bounding react of all the items in the scene. The QGV docs are also clear that QGS::sceneRect is used for “item indexing.”

    When would You ever want sceneRect on QGV to be different from sceneRect on QGS? That is, why isn’t there just a sceneRect on QGV? The only indication from the docs is that you may want the “item indexing” function on QGS to operate independently of the scrollable area of the QGV, but there is no indication of what “item indexing” is in order to decide which sceneRect property to set.

    Cheers,
    -Patrick

    https://alaskafamilysystems.com/

    A 1 Reply Last reply 4 Oct 2019, 11:22
    0
    • P patrickkidd
      5 Oct 2019, 21:13

      @Asperamanca Yes, that is the reason that the QGV sceneRect takes priority. However, I am specifically trying to figure out why there is a sceneRect property on QGS at all.

      A Offline
      A Offline
      Asperamanca
      wrote on 7 Oct 2019, 08:07 last edited by
      #4

      @patrickkidd

      1. You can have a scene without a view (yet). You may want to finish configuring the scene before you attach a view.
      2. As I wrote, it is relatively easy to get the scene rect from QGraphicsScene from within an item, but if the sceneRect existed only in the view, it would be more complicated, with more checks in the code.

      I would argue that most of the time, you attach a single view to the scene, and most of the time where you do attach multiple views, they will be able to share the sceneRect. In that view, overriding the sceneRect in the view is a special case of a special case. Great it is supported, but it should not make everyone's code more complicated.

      P 1 Reply Last reply 7 Oct 2019, 17:49
      0
      • P patrickkidd
        3 Oct 2019, 14:30

        The documentation is clear that QGraphicsView::sceneRect determines the extent of the scrollable area of the view, and that if this property is not explicitly set on the QGV then it is pulled from QGraphicsScene, and if this is not explicitly set then QGS::sceneRect returns the bounding react of all the items in the scene. The QGV docs are also clear that QGS::sceneRect is used for “item indexing.”

        When would You ever want sceneRect on QGV to be different from sceneRect on QGS? That is, why isn’t there just a sceneRect on QGV? The only indication from the docs is that you may want the “item indexing” function on QGS to operate independently of the scrollable area of the QGV, but there is no indication of what “item indexing” is in order to decide which sceneRect property to set.

        Cheers,
        -Patrick

        A Offline
        A Offline
        Asperamanca
        wrote on 4 Oct 2019, 11:22 last edited by
        #2

        @patrickkidd I'm just guessing here, but what if you display a single scene in multiple views, and e.g. want some of the views only to display a part of it? You could then simply restrict the scene rect on that view.

        On the other hand, if you want to access the sceneRect from within the scene, life would get a lot more complicated if you had to go via one of potentially multiple views.

        P 1 Reply Last reply 5 Oct 2019, 21:13
        0
        • A Asperamanca
          4 Oct 2019, 11:22

          @patrickkidd I'm just guessing here, but what if you display a single scene in multiple views, and e.g. want some of the views only to display a part of it? You could then simply restrict the scene rect on that view.

          On the other hand, if you want to access the sceneRect from within the scene, life would get a lot more complicated if you had to go via one of potentially multiple views.

          P Offline
          P Offline
          patrickkidd
          wrote on 5 Oct 2019, 21:13 last edited by
          #3

          @Asperamanca Yes, that is the reason that the QGV sceneRect takes priority. However, I am specifically trying to figure out why there is a sceneRect property on QGS at all.

          https://alaskafamilysystems.com/

          A 1 Reply Last reply 7 Oct 2019, 08:07
          0
          • P patrickkidd
            5 Oct 2019, 21:13

            @Asperamanca Yes, that is the reason that the QGV sceneRect takes priority. However, I am specifically trying to figure out why there is a sceneRect property on QGS at all.

            A Offline
            A Offline
            Asperamanca
            wrote on 7 Oct 2019, 08:07 last edited by
            #4

            @patrickkidd

            1. You can have a scene without a view (yet). You may want to finish configuring the scene before you attach a view.
            2. As I wrote, it is relatively easy to get the scene rect from QGraphicsScene from within an item, but if the sceneRect existed only in the view, it would be more complicated, with more checks in the code.

            I would argue that most of the time, you attach a single view to the scene, and most of the time where you do attach multiple views, they will be able to share the sceneRect. In that view, overriding the sceneRect in the view is a special case of a special case. Great it is supported, but it should not make everyone's code more complicated.

            P 1 Reply Last reply 7 Oct 2019, 17:49
            0
            • A Asperamanca
              7 Oct 2019, 08:07

              @patrickkidd

              1. You can have a scene without a view (yet). You may want to finish configuring the scene before you attach a view.
              2. As I wrote, it is relatively easy to get the scene rect from QGraphicsScene from within an item, but if the sceneRect existed only in the view, it would be more complicated, with more checks in the code.

              I would argue that most of the time, you attach a single view to the scene, and most of the time where you do attach multiple views, they will be able to share the sceneRect. In that view, overriding the sceneRect in the view is a special case of a special case. Great it is supported, but it should not make everyone's code more complicated.

              P Offline
              P Offline
              patrickkidd
              wrote on 7 Oct 2019, 17:49 last edited by
              #5

              @Asperamanca Ah. now I understand what you wrote in your original reply more clearly. That does make sense, and it looks like the implementation accomplishes that level of flexibility without compromising the most general case.

              https://alaskafamilysystems.com/

              1 Reply Last reply
              0

              5/5

              7 Oct 2019, 17:49

              • Login

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