From: Heli Hyvättinen Date: Sat, 27 Aug 2011 17:28:35 +0000 (+0300) Subject: Failed attempt to change a QML property from C++ X-Git-Tag: v1.9.0~4^2~2 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=312bd57b886093ab6c82e311bb52a47db4342f9f;p=chessclock Failed attempt to change a QML property from C++ --- diff --git a/chessclockview.cpp b/chessclockview.cpp index 7e07520..e04be9a 100644 --- a/chessclockview.cpp +++ b/chessclockview.cpp @@ -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()-> } } diff --git a/qml/ClocksPage.qml b/qml/ClocksPage.qml index 52a3a87..6a2e611 100644 --- a/qml/ClocksPage.qml +++ b/qml/ClocksPage.qml @@ -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 diff --git a/qml/main.qml b/qml/main.qml index d2bbd54..7adbe6a 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -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