summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigrid naevdal <sigrid.naevdal@nokia.com>2011-09-07 12:55:22 +0200
committersigrid naevdal <sigrid.naevdal@nokia.com>2011-09-07 12:58:30 +0200
commitb59c72a32027a4d9a18040e407df33c294244710 (patch)
tree9cc36f2a6de08a994101bf07d51a2b4cb1e0c8d6
Color change example
-rw-r--r--ColorChangerExample/colorChangerExample.pro8
-rw-r--r--ColorChangerExample/main.cpp47
-rw-r--r--ColorChangerExample/main.qml6
3 files changed, 61 insertions, 0 deletions
diff --git a/ColorChangerExample/colorChangerExample.pro b/ColorChangerExample/colorChangerExample.pro
new file mode 100644
index 0000000..6d5bc9a
--- /dev/null
+++ b/ColorChangerExample/colorChangerExample.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp
+QT+= declarative \ No newline at end of file
diff --git a/ColorChangerExample/main.cpp b/ColorChangerExample/main.cpp
new file mode 100644
index 0000000..31c2573
--- /dev/null
+++ b/ColorChangerExample/main.cpp
@@ -0,0 +1,47 @@
+#include <QtGui>
+#include <QtDeclarative>
+
+class Object : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor myColor READ getMyColor NOTIFY myColorChanged)
+
+public:
+ Object()
+ {
+ hue = 0;
+ startTimer(100);
+ }
+
+ QColor getMyColor()
+ {
+ return QColor::fromHslF(hue, 1, 0.5);
+ }
+
+ void timerEvent(QTimerEvent *)
+ {
+ hue += 0.01;
+ if (hue > 1)
+ hue = 0;
+ emit myColorChanged();
+ }
+
+signals:
+ void myColorChanged();
+
+private:
+ qreal hue;
+ };
+
+#include "main.moc"
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ Object myObj;
+ QDeclarativeView view;
+ view.rootContext()->setContextProperty("rootItem", (QObject *)&myObj);
+ view.setSource(QUrl::fromLocalFile("main.qml"));
+ view.show();
+ return app.exec();
+} \ No newline at end of file
diff --git a/ColorChangerExample/main.qml b/ColorChangerExample/main.qml
new file mode 100644
index 0000000..61a6158
--- /dev/null
+++ b/ColorChangerExample/main.qml
@@ -0,0 +1,6 @@
+import QtQuick 1.0
+
+Rectangle {
+ color: rootItem.myColor
+ width: 80; height: 80
+}