Can you create an about 100 lines example application that shows that bug so I can try out here?
Can you create an about 100 lines example application that shows that bug so I can try out here?
It's nice to be important but it's more important to be nice.
That's the simplest program. I even didn't have to implement connection objects to show result.
If you run it, make view smaller - to fit inside only one rectangle - and perform scroll down (with mouse or keys).
You'll see that part of rectangle which wasn't visible isn't redraw (small circles aren't draw entirely) .
http://www.nopaste.pl/Source/l5k.txt
EDIT:
And in this one I've added connections. Like above - this time ALL small circles (CRectSmall) are drawn, but only 2 or 3 of connections for each rectangle is being draw.
http://www.nopaste.pl/Source/l5n.txt
Last edited by T4ng10r; 21st January 2010 at 11:26.
But why are you using QGraphicsWidget's for such things, like drawing circles? Can't you use QGraphicsItem subclasses with properly implemented boundingRect() (and optionally shape()) and paint() ?
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
With reimplementing boundingRect I had lots of problems. Mainly positioning inside parents and on scene. In other situation I needed info about position of others scene object - but they weren't set till final object placement. QGraphicsWidget gave me ability to set size and pos and used them in other places without waiting for final scene placement where position and size are stored.
You didn't spend enough time on reading docs and analyzing given examples. Bounding rectangle is in item's coordinates so if you have rectangle item 20x20 then bounding rectangle returned by boundingRect() should QRectF(0,0,20,20).
Then drawing in paint() is also done in item's coordinates so doing like this:
will cause painting outside the item's bounding rect, which effects you can see in your app. The proper code would be:Qt Code:
painter->drawEllipse(pos().x(), pos().y(), 20, 20);To copy to clipboard, switch view to plain text mode
assuming that bounding rect is at least with w=20, h=20;Qt Code:
painter->drawEllipse(0, 0, 20, 20);To copy to clipboard, switch view to plain text mode
It is rather logical for me that item has no position if it is not added to any scene yet (or any parent) because there is no valid position. And notice that pos() is in parent's coordinates and scenePos() in scene's.Mainly positioning inside parents and on scene. In other situation I needed info about position of others scene object - but they weren't set till final object placement. QGraphicsWidget gave me ability to set size and pos and used them in other places without waiting for final scene placement where position and size are stored.
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
When I changed base class for Connection from QGraphicsWidget to QGraphicsPathItem - it solved my problem. I didn't even have to change or reimplement boudingRect() - it's done automatically.
Bookmarks