Hi at all,
I have in my scene a custom QGraphicsItem. When I apply to the scene a certain zoom it suddently disapperas? Why? And how can I prevent if from happening?
Thank you all, and sorry for my bad english!
Hi at all,
I have in my scene a custom QGraphicsItem. When I apply to the scene a certain zoom it suddently disapperas? Why? And how can I prevent if from happening?
Thank you all, and sorry for my bad english!
Can you post the code of your Item paint() method?
A camel can go 14 days without drink,
I can't!!!
This is my code.
Qt Code:
void CMCanvasPointer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); float x = center->x(); float y = center->y(); painter->drawRect(boundingRect()); }To copy to clipboard, switch view to plain text mode
It make a "+" in a scene and moving che point "center" it can translate in the window.
What is the value of length??
if length is 2, you're painting 4 points
Last edited by mcosta; 29th July 2011 at 11:05. Reason: updated contents
A camel can go 14 days without drink,
I can't!!!
length is a global variable and the value is 20.
From QT Docs
How do you set the boundingRect() ?void QGraphicsItem:aint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) [pure virtual]
...
Make sure to constrain all painting inside the boundaries of boundingRect() to avoid rendering artifacts (as QGraphicsView does not clip the painter for you).
...
Show the code of CMCanvasPointer::boundingRect().
A camel can go 14 days without drink,
I can't!!!
What zoom level does the object disappear at? You may be over- or under-flowing the painter's underlying units.
Bookmarks