Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

SetContextProperty and threading

$
0
0
I’m having a small issue with creating an object on a thread as well as setting it as a property in a qml view. I’m just wondering why this doesn’t work. I want the qml view to update while the work is being done but it does not. main .cpp   // create update thread     QThread sexyThread;     Sexy sexyWork;     sexyWork.moveToThread(&sexyThread);     updateThread.start();       // create view     QDeclarativeView view;     // hook up the update class to the view     view.rootContext()->setContextProperty("sexyView", &sexyWork);       // set the main view     view.setSource(QUrl("qrc:QML/main.qml"));   #ifdef TARGET     view.showFullScreen(); #else     view.show(); #endif     return app->exec(); main.qml       import Qt 4.7   Rectangle {     width: 800; height: 480       Connections {         target: sexyView     }       Text {         id: statusText         x: 327         y: 91         text: sexyView.getStatusToQML         anchors.topMargin: 91         anchors.top: parent.top     }       ProgressBar {         id: progress         x: 275         y: 139         value: sexyView.getProgressToQML     }       Button {         anchors.centerIn: parent         onClicked: sexyView.runUpdate()     } }

Viewing all articles
Browse latest Browse all 18427

Trending Articles