From 93a32ca25fdec3e38f03c0779bf9850ca13e7987 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Sat, 27 Aug 2011 21:12:37 +0300 Subject: [PATCH] Reache QML from C++, still not working --- chessclockview.cpp | 16 ++++++++-------- qml/main.qml | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chessclockview.cpp b/chessclockview.cpp index e04be9a..7f46774 100644 --- a/chessclockview.cpp +++ b/chessclockview.cpp @@ -1,10 +1,12 @@ #include "chessclockview.h" #include #include +#include ChessClockView::ChessClockView(QWidget *parent) : QDeclarativeView(parent) { + } bool ChessClockView::event(QEvent *event) @@ -12,21 +14,19 @@ bool ChessClockView::event(QEvent *event) if (event->type() == QEvent::WindowDeactivate) { - QDeclarativeContext * pContext = rootContext(); + QDeclarativeContext * pContext = new QDeclarativeContext (rootContext()); if (pContext) { - QObject * pObject = pContext->contextObject(); - if (pObject) - { - pObject->setProperty("applicationActive",false); -// pContext->setContextProperty("clocksPage.applicationActive", false); +// pContext->setContextProperty("applicationActive", false); qDebug() << "Window deactivated"; - } - else qDebug() << "No context object!" << pContext->isValid(); + // QDeclarativeEngine * pEngine = engine(); // engine()-> } + + QGraphicsObject *pObject = rootObject(); + pObject->setProperty("applicationActive",false); } else if (event->type() == QEvent::WindowActivate) diff --git a/qml/main.qml b/qml/main.qml index 7adbe6a..e8a4ef7 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -29,9 +29,11 @@ PageStackWindow { property bool applicationActive: true //This is supposed to be set from C++ - onApplicationActiveChanged: + property bool appActive: applicationActive + + onAppActiveChanged: { - if (applicationActive == false) + if (appActive == false) wrappedClocksWidget.pause() theme.inverted = false } -- 1.7.9.5