Update scene
-
if pos() returns 0,0 , it must mean the items is actually at 0,0.
-
@mandruk1331
Something is not right.
Unless they are all really drawn at 0,0 then pos() should return the
actual position.
Did you new a QGraphicsRectItem and inserted directly in the list? -
Ok, then they should still have the pos, unless you swapped with a
item having 0,0. -
Can I ask how any values (rects) you try to visualize?
-
@mandruk1331
ok.
And did you write the sort also? -
ok.
Don't really look like bubble sort.
:) -
Hi
I made a half assed bubble sort visualization using
widget painting.2 things wrong with it.
The actual sort should rather be able to single step but instead
I use a delay function to slow down drawing. (not pretty)
So consider it concept rather than good practice.That said, its meant for inspiration for your project.
-
I know I'm late to the party, but for what it's worth:
- There is rarely ever a need to manually update the GraphicsScene. It will automatically update parts whenever you move items (setPos), or change properties of ready-to-use items such as QGraphicsRectItem
- If you implement your own item and your own paint method, naturally the scene cannot know which properties will affect the paint and which won't. Therefore, you just call update() on the item after you changed any properties that affect the way the item looks
- If you change the boundingRect(), don't forget to call prepareGeometryChange(), otherwise you will have nasty painting effects
- Re sorting: qSort, anyone?