<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Hello fellow SailfishDevel list members,</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;"> </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;">I'm writing a QML/Sailfish Silica app that will use the logic of a CLI C++ application I had already written. I've also already created a QML/Silica UI. So I will need to let C++ and QML communicate (for example the C++ code has to know when a QML Button is clicked)</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;">and the C++ code will need to change the properties (for example text of a label) of QML items.</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;"> </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt;">I'm still quite new to programming and Qt/QML, so I'm still figuring out how to let C++ and QML communicate with each other (which is the most difficult part in programming for me until now). I'm currently reading </span><a href="http://qt-project.org/doc/qt-4.8/qdeclarativecontext.html"><span style=" font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#006e28;">Qt Docs QDeclarativeContext</span></a><span style=" font-family:'Sans Serif'; font-size:9pt;"> . The Qt Docs says that you should create a QDeclarativeContext object first to be able to change QML properties from C++, but to create a context you need to pass the QDeclarativeEngine object as a parameter:</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534; background-color:#f6f6f6;"> </span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534;">QDeclarativeContext </span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#202020;">*</span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534;">context </span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#202020;">=</span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534;"> </span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#840000;">new</span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534;"> QDeclarativeContext(engine</span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#202020;">.</span><span style=" font-family:'Sans Serif'; font-size:9pt; color:#363534;">rootContext());</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt; color:#000000;">However the Sailfish example application (on which I based my app) is initialized differently than a normal QML application (like those on the Qt Docs). So does the Sailfish example application (I mean the sailfishapplication.cpp and main.cpp parts) create a QDeclarativeEngine object?</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt; color:#000000;">In other words: are those Sailfish namespace functions just a wrapper of the normal Qt initialization calls with special parameters for Sailfish apps? (it looks like that to me)</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt; color:#000000;">Thanks in advance,</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Sans Serif'; font-size:9pt; color:#000000;">Superpelican :)</span></p></div></body></html>