qtmobility/examples/sensors/grueapp/main.cpp
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qtmobility/examples/sensors/grueapp/main.cpp	Fri Apr 16 15:51:22 2010 +0300
@@ -0,0 +1,34 @@
+#include <QtCore>
+#include <qsensor.h>
+
+QTM_USE_NAMESPACE
+
+class Filter : public QSensorFilter
+{
+public:
+    bool filter(QSensorReading *reading)
+    {
+        int percent = reading->property("chanceOfBeingEaten").value<qreal>() * 100;
+        qDebug() << "Your chance of being eaten by a Grue:" << percent << "percent.";
+        return false;
+    }
+};
+
+int main(int argc, char **argv)
+{
+    QCoreApplication app(argc, argv);
+
+    QSensor sensor;
+    sensor.setType("GrueSensor");
+    if (!sensor.connect()) {
+        qWarning("Grue sensor is not available!");
+        return 1;
+    }
+
+    Filter filter;
+    sensor.addFilter(&filter);
+    sensor.start();
+
+    return app.exec();
+}
+