| 48 | }; |
| 49 | |
| 50 | int main(int argc, char **argv) |
| 51 | { |
| 52 | QApplication app(argc, argv); |
| 53 | |
| 54 | QWidget w; |
| 55 | auto layout = new QVBoxLayout(&w); |
| 56 | |
| 57 | auto btn = new QPushButton("Create QTimer", &w); |
| 58 | QObject::connect(btn, &QPushButton::clicked, &w, [&w]() { |
| 59 | //! [Missing setSingleShot] |
| 60 | auto timer = new QTimer(&w); |
| 61 | QObject::connect(timer, &QTimer::timeout, &w, [&w] { w.repaint(); }); |
| 62 | timer->setInterval(0); |
| 63 | // timer->setSingleShot(true); |
| 64 | timer->start(); |
| 65 | //! [Missing setSingleShot] |
| 66 | }); |
| 67 | layout->addWidget(btn); |
| 68 | |
| 69 | btn = new QPushButton("Start Timer", &w); |
| 70 | QObject::connect(btn, &QPushButton::clicked, &w, [&w]() { |
| 71 | auto timer = new MyUpdateTimer(&w, &w); |
| 72 | timer->start(); |
| 73 | }); |
| 74 | layout->addWidget(btn); |
| 75 | |
| 76 | w.show(); |
| 77 | return app.exec(); |
| 78 | } |
| 79 | |
| 80 | #include "timer.moc" |