summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorMorten Sørvig <msorvig@trolltech.com>2009-02-12 16:31:55 +0100
committerMorten Sørvig <msorvig@trolltech.com>2009-02-12 16:31:55 +0100
commitc121bc7d39e75f78bb71ff422b8263b68c80c60a (patch)
tree936ceef57ac00167353973fcffda1e3c0d41a67c /demos
parentc52c64cf123e1509b3ccd9ce97bd5d6022b7934e (diff)
Use a psubutton to start the timer.
Diffstat (limited to 'demos')
-rwxr-xr-xdemos/timer/main.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/demos/timer/main.cpp b/demos/timer/main.cpp
index eeb64c2..2051511 100755
--- a/demos/timer/main.cpp
+++ b/demos/timer/main.cpp
@@ -7,15 +7,18 @@ Q_OBJECT
public:
LabelUpdater()
{
- QTimer *timer = new QTimer(this);
+ timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
- timer->start(2000);
label= new QLabel(this);
- label->resize(200, 20);
+ label->resize(50, 20);
label->move(20,20);
- label->setText("foo");
-
+ label->setText("0");
+
+ startButton = new QPushButton(this);
+ startButton->setText("Start Timer");
+ connect(startButton, SIGNAL(clicked()), SLOT(startTimer()));
+
counter = 0;
}
@@ -24,9 +27,17 @@ public slots:
{
label->setText(QString::number(counter++));
}
+
+ void startTimer()
+ {
+ timer->start(500);
+ }
+
private:
int counter;
+ QTimer *timer;
QLabel *label;
+ QPushButton * startButton;
};