GraphicsView: Artifacts after reducing boundingRect size - scene()->update() does nothing
-
Hi,
That's maybe related to the viewport update mode.
-
Hi,
That's maybe related to the viewport update mode.
wrote on 9 Feb 2017, 08:06 last edited by@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?
-
Sorry, I can't answer that one, a look at the algorithm used might give you more information about that.
-
Sorry, I can't answer that one, a look at the algorithm used might give you more information about that.
wrote on 10 Feb 2017, 08:48 last edited by@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... -
wrote on 10 Feb 2017, 09:20 last edited by BjornW 2 Oct 2017, 09:20
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.
-
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.
wrote on 10 Feb 2017, 09:28 last edited by@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. -
wrote on 10 Feb 2017, 11:18 last edited by
Can you post code?
I do not think that QGraphicsScene takes anything into account regarding brushes etc.
-
wrote on 10 Feb 2017, 12:14 last edited by
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());
-
wrote on 10 Feb 2017, 15:12 last edited by
How do you update the bounding rect?
-
wrote on 13 Feb 2017, 09:18 last edited by Asperamanca
By calling "prepareGeometryChange()" and then changing the fundamental parameters that are used in my overload of boundingRect()
11/11