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. GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing
Forum Updated to NodeBB v4.3 + New Features

GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing

Scheduled Pinned Locked Moved Unsolved General and Desktop
graphicsviewpainting
11 Posts 3 Posters 4.2k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    That's maybe related to the viewport update mode.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    A 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      That's maybe related to the viewport update mode.

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

      @SGaist said in GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing:

      Hi,

      That's maybe related to the viewport update mode.

      Good hint! Viewport update modes Minimal and Smart show the incorrect repaint, while viewport modes Full and BoundingRect display correctly.

      The documentation on the modes is a bit thin...why would Minimal and Smart conclude that an area does not need to redraw, even though I explicitly call update() on the item?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Sorry, I can't answer that one, a look at the algorithm used might give you more information about that.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        0
        • SGaistS SGaist

          Sorry, I can't answer that one, a look at the algorithm used might give you more information about that.

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

          @SGaist said in GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing:

          Sorry, I can't answer that one, a look at the algorithm used might give you more information about that.

          I have tried, but debugging this part of code is not easily done, because switching between debugger and applications triggers invalidates and repaints.
          Also, watching regions in the debugger is not easily done...

          1 Reply Last reply
          0
          • BjornWB Offline
            BjornWB Offline
            BjornW
            wrote on last edited by BjornW
            #6

            Do you make sure to paint inside the bounding rect? If you have, let's say, a 200x200 rect that you draw with 2p brush width, the bounding rect is actually 202x202.

            Usually this means, if you want to draw a 200x200 rect with 2p brush width, you should draw a 198x198 rect to keep everything inside the 200x200 bounding rect.

            A 1 Reply Last reply
            0
            • BjornWB BjornW

              Do you make sure to paint inside the bounding rect? If you have, let's say, a 200x200 rect that you draw with 2p brush width, the bounding rect is actually 202x202.

              Usually this means, if you want to draw a 200x200 rect with 2p brush width, you should draw a 198x198 rect to keep everything inside the 200x200 bounding rect.

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

              @BjornW said in GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing:

              Do you make sure to paint inside the bounding rect? If you have, let's say, a 200x200 rect that you draw with 2p brush width, the bounding rect is actually 202x202.

              Usually this means, if you want to draw a 200x200 rect with 2p brush width, you should draw a 198x198 rect to keep everything inside the 200x200 bounding rect.

              I know the artifacts I get when I do this mistake: A thin border around the area of the old bounding rect. However, in my case the artifacts practically fill the old bounding rect.
              Also, all my pens are hairline (1 px cosmetic), and GraphicsView normally takes that one pixel around the boundingRect into account, if memory serves me.

              1 Reply Last reply
              0
              • BjornWB Offline
                BjornWB Offline
                BjornW
                wrote on last edited by
                #8

                Can you post code?

                I do not think that QGraphicsScene takes anything into account regarding brushes etc.

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

                  For one thing, here is how it looks with artefacts:

                  Screenshot
                  Each of the colorful rectangles is a GraphicsItem. The "old" boundingRect has a width of 981 px. The "new" boundingRect is half as wide, and slightly to the left of the center. All colored areas above and below the dashed line should be black with a gray grid.

                  The paint code is simple. This is not the original code, but sufficient to cause the effect.

                      painter->setPen(Qt::NoPen);
                      painter->setBrush(QBrush(m_LinePen.color()));
                      painter->drawRect(boundingRect());
                  
                  1 Reply Last reply
                  0
                  • BjornWB Offline
                    BjornWB Offline
                    BjornW
                    wrote on last edited by
                    #10

                    How do you update the bounding rect?

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

                      By calling "prepareGeometryChange()" and then changing the fundamental parameters that are used in my overload of boundingRect()

                      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