I am trying to construct an odometer in qt.The Idea is that I draw a convex polygon using QPainter , and then I rotate the QPainter instance using the QPainter::rotate()
function ,followed by a QLabel::setPixmap()
to update it on the screen, however , I can see the previously drawn polygons , how can I get rid of them?I know of eraserect function , but I'm looking for a better alternative since eraserect erases the entire rectangle.Also, is there a way where I don't have to call setpixmap again and again? Here's the code:
for(int i=0;i<23;i++)
{
paint.rotate(8); // paint is a QPainter instance initialized with a QPixmap instance
paint.drawConvexPolygon(pts , 3);
ui->needle->setPixmap(pin);
}
question from:
https://stackoverflow.com/questions/65829469/how-to-clear-previously-drawn-polygons-before-rotating-qpainter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…