Store data about the circles and access it during next mousepress.
// assuming QVector<QPair<QPoint, int> > circles is a member variable of the class
switch(circles.count()){
case 0: case 1: circles << qMakePair(me->pos(), 30); break;
case 2: circles.clear();
}
update();
}
for(int i=0;i<circles.count();i++){
painter.drawEllipse(circles[i].first, circles[i].second, circles[i].second);
}
}
void xxx::mousePressEvent(QMouseEvent *me){
// assuming QVector<QPair<QPoint, int> > circles is a member variable of the class
switch(circles.count()){
case 0: case 1: circles << qMakePair(me->pos(), 30); break;
case 2: circles.clear();
}
update();
}
void xxx::paintEvent(QPaintEvent *pe){
QPainter painter(this);
for(int i=0;i<circles.count();i++){
painter.drawEllipse(circles[i].first, circles[i].second, circles[i].second);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks