Failed attempt to change a QML property from C++
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 27 Aug 2011 17:28:35 +0000 (20:28 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 27 Aug 2011 17:28:35 +0000 (20:28 +0300)
chessclockview.cpp
qml/ClocksPage.qml
qml/main.qml

index 7e07520..e04be9a 100644 (file)
@@ -15,8 +15,17 @@ bool ChessClockView::event(QEvent *event)
         QDeclarativeContext * pContext = rootContext();
         if (pContext)
         {
-            pContext->setContextProperty("clocksPage.applicationActive", false);
+            QObject * pObject = pContext->contextObject();
+
+            if (pObject)
+            {
+                pObject->setProperty("applicationActive",false);
+//            pContext->setContextProperty("clocksPage.applicationActive", false);
             qDebug() << "Window deactivated";
+            }
+            else qDebug() << "No context object!" << pContext->isValid();
+//            QDeclarativeEngine * pEngine = engine();
+//            engine()->
         }
     }
 
index 52a3a87..6a2e611 100644 (file)
@@ -30,7 +30,6 @@ Page
 {
     id: clocksPage
 
-    property bool applicationActive: true //This is supposed to be set from C++
 
     property int timeControl //properties cannot be declared as enumerations in QML
                              //...must be a valid enum from WrappedClocksWidget
@@ -49,13 +48,6 @@ Page
             wrappedClocksWidget.startGame(timeControl,whiteInitialTime,whiteAdditionalTime,whiteTurnsPerAddition,blackInitialTime,blackAdditionalTime,blackTurnsPerAddition)
     }
 
-    onApplicationActiveChanged:
-    {
-        if (applicationActive == false)
-            wrappedClocksWidget.pause()
-
-
-    }
 
 
     tools: ToolBarLayout
index d2bbd54..7adbe6a 100644 (file)
@@ -26,6 +26,17 @@ import com.meego 1.0
 PageStackWindow {
     id: appWindow
 
+
+    property bool applicationActive: true //This is supposed to be set from C++
+
+    onApplicationActiveChanged:
+    {
+        if (applicationActive == false)
+            wrappedClocksWidget.pause()
+            theme.inverted = false
+    }
+
+
     Component.onCompleted: theme.inverted = true
 
     initialPage: mainPage