From: Kevin Krammer Date: Wed, 13 Mar 2013 13:47:00 +0000 (+0100) Subject: Timer available as a type now, remove exported object from runner X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=1b1d9625e20abf9370030b059f282c05cdfcd828;p=web%2Fkonrad%2FDeclarativeWidgets.git Timer available as a type now, remove exported object from runner --- diff --git a/examples/test.qml b/examples/test.qml index 8627793..48be168 100644 --- a/examples/test.qml +++ b/examples/test.qml @@ -18,13 +18,14 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import QtQuick 1.0 +import QtCore 1.0 import QtGui 1.0 Widget { windowTitle: qsTr("Cool Test App") size: Qt.size(300, 500) + property int counter: 0 function myFunc() @@ -32,12 +33,21 @@ Widget { counter++; } - Component.onCompleted: _timer.timeout.connect(myFunc) + Timer { + id: timer + interval: 1000 + onTimeout: myFunc() + } VBoxLayout { Label { text: "Hallo ASCII-safe Kevin!!! " + counter } + PushButton { + text: "Run Timer" + checkable: true + onToggled: checked ? timer.start() : timer.stop() + } Label { id: secondLabel text: "Wie geht es" diff --git a/main.cpp b/main.cpp index 1305e2d..533997c 100644 --- a/main.cpp +++ b/main.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include int main(int argc, char **argv) @@ -38,18 +37,12 @@ int main(int argc, char **argv) return -1; } - QTimer timer; - timer.setInterval(1000); - timer.start(); - const QFileInfo qmlFile(QDir::current(), arguments[1]); const QUrl documentUrl = QUrl::fromLocalFile(qmlFile.absoluteFilePath()); DeclarativeWidgetsDocument document(documentUrl); QObject::connect(document.engine(), SIGNAL(quit()), &app, SLOT(quit())); - document.setContextProperty("_timer", &timer); - QWidget *widget = document.create(); if (widget) widget->show();