<div dir="ltr"><div>Thanks, actually i had already seen that but couldn't accomplish much, now i tried again and i managed to access and edit qml properties, but the QML object doesn't update.<br><br></div>i use this code in a c++ method<br><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">    QQmlEngine engine;<br>    QQmlComponent component (&engine, "/usr/share/harbour-pocketmonsters/qml/pages/FirstPage.qml");<br>    QObject *object = component.create();<br>    QObject *label = object->findChild<QObject*>("label");<br><br>    cout << label->property("text").toString();<br><br>    if (label)<br>        label->setProperty("text", <a href="http://active.name">active.name</a>);<br><br>    cout << label->property("text").toString();<br></blockquote><div><br></div><div>the output of cout is correct, but the label doesn't update <br><br></div><div>The console shows these errors, but i think they are irrelevant since the output is correct<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:'Monospace';font-size:9pt;color:#be1414">[W] unknown:108 - </span><a><span style="font-family:'Monospace';font-size:9pt;text-decoration:underline;color:#1414be">file:///usr/lib/qt5/qml/Sailfish/Silica/Page.qml:108</span></a><span style="font-family:'Monospace';font-size:9pt;color:#be1414">: ReferenceError: __silica_applicationwindow_instance is not defined</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:'Monospace';font-size:9pt;color:#be1414">[W] unknown:94 - </span><a><span style="font-family:'Monospace';font-size:9pt;text-decoration:underline;color:#1414be">file:///usr/lib/qt5/qml/Sailfish/Silica/Page.qml:94</span></a><span style="font-family:'Monospace';font-size:9pt;color:#be1414">: ReferenceError: __silica_applicationwindow_instance is not defined</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:'Monospace';font-size:9pt;color:#be1414">[W] unknown:178 - </span><a><span style="font-family:'Monospace';font-size:9pt;text-decoration:underline;color:#1414be">file:///usr/lib/qt5/qml/Sailfish/Silica/Page.qml:178</span></a><span style="font-family:'Monospace';font-size:9pt;color:#be1414">: ReferenceError: __silica_applicationwindow_instance is not defined</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:'Monospace';font-size:9pt;color:#3c3c3c">[W] unknown:331 - </span><a><span style="font-family:'Monospace';font-size:9pt;text-decoration:underline;color:#1414be">file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:331</span></a><span style="font-family:'Monospace';font-size:9pt;color:#3c3c3c">: ReferenceError: __silica_applicationwindow_instance is not defined</span></p></blockquote></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-08-13 15:17 GMT+02:00 Andrea Bernabei <span dir="ltr"><<a href="mailto:and.bernabei@gmail.com" target="_blank">and.bernabei@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br><br></div>try having a look at this <br><a href="http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html" target="_blank">http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html</a><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2015-08-13 14:14 GMT+01:00 Antonio Mancini <span dir="ltr"><<a href="mailto:ziobilly94@gmail.com" target="_blank">ziobilly94@gmail.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hi all, i need to access a property of a C++ Class, declared inside another class, from QML.<br><br></div>This is the principal class:<br><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">#ifndef MANAGER_H<br>#define MANAGER_H<br><br>#include <QObject><br>#include <QTextStream><br>#include <QFile><br>#include "monster.h"<br>#include "move.h"<br>#include "turnmanager.h"<br><br><br>class Manager : public QObject<br>{<br>    Q_OBJECT<br><br>public:<br>    explicit Manager(QObject *parent = 0);<br><br>    int activeId;<br>    QString activeString;<br><br>    int enemyId;<br><br>    Monster active;<br>    Monster enemy;<br>    <br>    Move activeMove;<br>    Move enemyMove;<br><br>    Q_INVOKABLE void saveActive();<br>    Q_INVOKABLE void fetchMonster( const int &level );<br>    Q_INVOKABLE void assignMoves(Monster &monster );<br>    Q_INVOKABLE void setMove( Move &move, const int &id );<br><br>signals:<br><br>    void fetchMonsterDone();<br><br>public slots:<br><br>};<br><br>#endif // MANAGER_H<br></blockquote><br></div><div>this is the Monster Class:<br></div><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">#ifndef MONSTER_H<br>#define MONSTER_H<br><br>#include <QObject><br>#include <QString><br>#include <math.h><br>#include "move.h"<br><br><br>class Monster : public QObject<br>{<br>    Q_OBJECT<br><br>public:<br><br>    explicit Monster(QObject *parent = 0);<br><br>    ...<br><br>    QString name;<br><br>    ...<br>};<br><br>#endif // MONSTER_H<br></blockquote><br></div><div>in my qml page i include the class properly and i have something like this:<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Page {<br></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>    id: page</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>    Manager {</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>        id: manager</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>        onFetchMonsterDone: {</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>             console.log("Fetch done")<br>        }<br></div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>    }</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>    Label {</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>        id: label</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>    }</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>} <br></div></blockquote></div><div><br></div><div>after doing some operations with fetchMonster(), the "active" class has been assigned some values to its properties, i need to access these values from QML in the "onFetchMonsterDone", let's say i need to assign to label.text the value of <a href="http://manager.active.name" target="_blank">manager.active.name</a><br><br></div><div>OR<br><br></div><div>i read there are some ways to access end edit QML properties from C++<br><br></div><div>Can someone help me? <br></div></div>
<br></div></div>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>