11 #include <QPaintEvent> 12 #include <QMouseEvent> 13 #include <QMainWindow> 14 #include <QApplication> 22 widget.updatePosition(1);
35 static const int nb_points = 2;
36 QPainter painter(
this);
37 const QRect& drawing_rect =
event->rect();
38 const QPoint *points[nb_points] = {&aimed, &position};
39 const Qt::GlobalColor colors[nb_points] = {Qt::green, Qt::blue};
41 painter.eraseRect(drawing_rect);
42 for(
int i = 0; i < nb_points; i++) {
43 painter.setPen(colors[i]);
44 painter.setBrush(colors[i]);
45 painter.drawPie(region(*points[i]), 0, 360 * 16);
52 if (event->buttons() & Qt::LeftButton)
53 modify( aimed, event->pos() );
61 int main(
int argc,
char** argv) {
62 QApplication app(argc, argv);
63 QMainWindow mainWindow;
65 centralWidget.setMinimumSize(300,200);
67 mainWindow.setCentralWidget(¢ralWidget);
71 app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
bool still_running
Should the thread continue to run?
void updatePosRequest(const int dist)
Sends a signal to ask for an update of the widget.
void run()
The main method of this thread.