gab74
6th March 2013, 16:54
Good morning,
i've to draw an arrow on a widget. so i have the xpm file for the arrow.
I draw the arrow only if the new angle is more than 5 degree.
Problem is that on my widget i see the arrow, then it disappears and come back only when the drawship metod is call again, then disappears again..and so on..as flickering...
I thought that when drawpxmap draws the image it remains on the widget untill a new drawpixmap will be called...
What is my error ?
This is the simple code :
void Class:: paintEvent(QPaintEvent *event)
{
if(fabs(New_Heading - OSHeading) > 5 )
{
drawShip();
}
}
void Class::drawShip()
{
QRegion myregion1(X_Background_PPI, Y_Background_PPI, PPI_SIZE, PPI_SIZE);
QPainter painter1(this);
painter1.setClipRegion(myregion1);
painter1.setRenderHint(QPainter::Antialiasing, true);
painter1.save(); // save the current printer settings before changing them
painter1.translate(X_Nave_PPI,Y_Nave_PPI); // // the point about which the image rotates
painter1.rotate(New_Heading); //degrees;
painter1.drawPixmap(-Nave_PPI.width()/2, - Nave_PPI.height()/2, ARROW_PPI );
painter1.restore(); // // restore the previous painter settings
}
i've to draw an arrow on a widget. so i have the xpm file for the arrow.
I draw the arrow only if the new angle is more than 5 degree.
Problem is that on my widget i see the arrow, then it disappears and come back only when the drawship metod is call again, then disappears again..and so on..as flickering...
I thought that when drawpxmap draws the image it remains on the widget untill a new drawpixmap will be called...
What is my error ?
This is the simple code :
void Class:: paintEvent(QPaintEvent *event)
{
if(fabs(New_Heading - OSHeading) > 5 )
{
drawShip();
}
}
void Class::drawShip()
{
QRegion myregion1(X_Background_PPI, Y_Background_PPI, PPI_SIZE, PPI_SIZE);
QPainter painter1(this);
painter1.setClipRegion(myregion1);
painter1.setRenderHint(QPainter::Antialiasing, true);
painter1.save(); // save the current printer settings before changing them
painter1.translate(X_Nave_PPI,Y_Nave_PPI); // // the point about which the image rotates
painter1.rotate(New_Heading); //degrees;
painter1.drawPixmap(-Nave_PPI.width()/2, - Nave_PPI.height()/2, ARROW_PPI );
painter1.restore(); // // restore the previous painter settings
}