<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I'm trying to create a hybrid QML/C++ application, where the logic
    is written in C++ and the interface is QML/Sailfish Silica based.<br>
    <br>
    I'm currently playing around with the different ways to let QML/C++
    communicate with each other. I currently have this code:<br>
    <br>
    <code><br>
    #include <QApplication><br>
    #include <QGraphicsObject><br>
    #include <QDir><br>
    #include <QDeclarativeView><br>
    #include <QDeclarativeContext><br>
    #include <QDeclarativeEngine><br>
    #include <QDeclarativeComponent><br>
    #include <QDebug><br>
    #include <QDeclarativePropertyMap><br>
    <br>
    #ifdef HAS_BOOSTER<br>
    #include <MDeclarativeCache><br>
    #endif<br>
    <br>
    Q_DECL_EXPORT int main(int argc, char *argv[])<br>
    {<br>
        #ifdef HAS_BOOSTER<br>
            QScopedPointer<QApplication>
    myapp(MDeclarativeCache::qApplication(argc, argv));<br>
        #else<br>
            QScopedPointer<QApplication> myapp = new
    QApplication(argc, argv);<br>
        #endif<br>
    <br>
    <br>
        #ifdef HAS_BOOSTER<br>
            QScopedPointer<QDeclarativeView>
    appview(MDeclarativeCache::qDeclarativeView());<br>
        #else<br>
            QScopedPointer<QDeclarativeView>(new
    QDeclarativeView);<br>
        #endif<br>
    <br>
        QDeclarativePropertyMap binding_map;<br>
        binding_map.insert("question_txt", QVariant(QString("5 * 5
    =")));<br>
        binding_map.insert("color", QVariant(QString("dark red")));<br>
        QScopedPointer<QDeclarativeContext>
    binding_context(appview->rootContext());<br>
        binding_context->setContextProperty("binding_map",
    &binding_map);<br>
        QString file = "main.qml";<br>
        QString path = QString(DEPLOYMENT_PATH);<br>
        appview->setSource(QUrl::fromLocalFile(path + file));<br>
       
    appview->setResizeMode(QDeclarativeView::SizeRootObjectToView);<br>
        appview->setAttribute(Qt::WA_OpaquePaintEvent);<br>
        appview->setAttribute(Qt::WA_NoSystemBackground);<br>
       
    appview->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);<br>
       
    appview->viewport()->setAttribute(Qt::WA_NoSystemBackground);<br>
        appview->showFullScreen();<br>
        binding_map["question_txt"] = QVariant(QString("overwritten 5 *
    5 ="));<br>
        return myapp->exec();<br>
    }<br>
    </code><br>
    I need to let C++ print text in the QML interface (the question) and
    C++ has to obtain the<br>
    answer the user has answered in the QML interface (TextField Silica
    component). That's basically<br>
    the needed communication between C++ and QML.<br>
    <br>
    So I thought that I'd create a QDeclarativePropertyMap in C++. This
    propertymap will contain the question.<br>
    My program has a while loop that asks the user new questions each
    time the loop runs(the logic code can be found <a
      href="https://bitbucket.org/Superpelican/clamshell_cli">here</a>,
    <br>
    but it hasn't been adjusted for use with a GUI, it's currently a CLI
    application). So I need to constantly update the QML UI from C++<br>
    while the programs running, after I've setup the QDeclarativeView
    etc.<br>
    <br>
    However I noticed that if you change a value in the propertymap
    after initializing and showing the QDeclarativeView, the UI won't be
    updated!<br>
    I thought the QDeclarativePropertyMap was dynamic! <a
href="http://qt-project.org/doc/qt-4.8/qdeclarativepropertymap.html#details">http://qt-project.org/doc/qt-4.8/qdeclarativepropertymap.html#details</a>:
    "The binding is dynamic - whenever a key's value is updated,
    anything bound to that key will be updated as well."<br>
    <br>
    Kind Regards,<br>
    <br>
    Superpelican<br>
    <br>
    <br>
  </body>
</html>