PDA

View Full Version : background painting in the Scene



maverick_pol
7th January 2008, 19:44
Hi,

I have a question about some painter behaviour.
I have overloaded the the drawBackground for my scene. When a user sets m_draw flag to true some text should be drawn:


void GScene::drawBackground(QPainter *painter, const QRectF &rect)
{
....some drawing
if(m_draw)
{
painter->drawText(QPointF(0,0),"Text");
}
}


But the "Text" is not drawn. When I invalidate the scene and (m_draw==TRUE), while debugging, I see that the code is invoked, but nothing is drawn. In the console nothing is printed, no warning, no error.

Thanks for any help.

P.S.

I have also tried this, and it works...


....
if(1)
{
if(1)
{
painter->drawText(QPointF(0,0),"Text2");
}
}
.....

marcel
7th January 2008, 19:46
What color are the text and the background?
Maybe the scene coordinate (0,0) is outside the view...

maverick_pol
7th January 2008, 19:52
Hi,

For 100% the color is ok. To proove it I have done this and get the "Text1" at the (0,0), but still no text2.



....
painter->drawText(QPointF(0,0),"TExt1");
if(m_draw) /(*!< m_draw for 100% equals true*/
{
painter->drawText(QPointF(0,0),"Text2");
}
....


That's a bit strange.

marcel
7th January 2008, 20:02
Then the problem must be with the boolean variable.
Do you modify it from other threads?

maverick_pol
7th January 2008, 20:56
Ok,

Sorry for misleading a bit. I have found the mistake. I have been invalidating a rect which was to small.

Thank you for help

Maverick