6 MyWidget::MyWidget(QWidget
*parent
)
15 void MyWidget::paintEvent(QPaintEvent
*event
)
19 if (m_points
.size() == 1) {
20 // draw only one Point
21 p
.drawPoint(m_points
[0]);
26 QPolygon
poly(m_points
);
27 p
.setBrush(Qt::green
);
28 p
.setRenderHints(QPainter::Antialiasing
, true);
32 void MyWidget::mousePressEvent(QMouseEvent
*event
)
34 if (event
->button() == Qt::LeftButton
)
35 m_points
.append(event
->pos());
36 else if (event
->button() == Qt::RightButton
)