I have started learning Qt recently.
I did not get quite clear how can I paint using QPainter class. Let`s say I want just to place a few points in the window:
class PointDrawer: public QWidget {
Q_OBJECT
private:
QPainter p;
public:
PointDrawer(QWidget* obj=0): QWidget(obj), p(this) {}
virtual void paintEvent(QPaintEvent*) {
p.setPen(QPen(Qt::black, 3));
int n = 8;
while(...) {
qreal fAngle = 2 * 3.14 * i / n;
qreal x = 50 + cos(fAngle) * 40;
qreal y = 50 + sin(fAngle) * 40;
p.drawPoint(QPointF(x, y));
i++;
}
}
}
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
PointDrawer drawer;
drawer.resize(200, 200);
drawer.show();
return app.exec();
}
and after that I got nothing! Can you please tell me where I am wrong?