{
linepen.setCapStyle(Qt::RoundCap);
linepen.setWidth(25);
painter
->setRenderHint
(QPainter::Antialiasing,
true);
painter->setPen(linepen);
drawing(painter);
}
void mainwindow
::drawing(QPainter *painter
) {
painter->drawLine(point,point2);
timer3->start(200);
connect(timer3,
SIGNAL(timeout
()),
this,
SLOT(erase
(QPainter *)));
}
void mainwindow
::erase(QPainter *painter
) {
painter->eraseRect(100,40,550,440);
timer3->stop();
}
{
void mainwindow::paintEvent(QPaintEvent *e)
{
painter=new QPainter(this);
QPen linepen(Qt::red);
linepen.setCapStyle(Qt::RoundCap);
linepen.setWidth(25);
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(linepen);
drawing(painter);
}
void mainwindow::drawing(QPainter *painter)
{
painter->drawLine(point,point2);
timer3 = new QTimer(this);
timer3->start(200);
connect(timer3, SIGNAL(timeout()), this, SLOT(erase(QPainter *)));
}
void mainwindow::erase(QPainter *painter)
{
painter->eraseRect(100,40,550,440);
timer3->stop();
}
{
To copy to clipboard, switch view to plain text mode
I have to erase the line i have drawn after 200ms. But this code doesnot work what can i do?
Bookmarks