<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Actually, I think you're creating a new
instance of the FirstPage.qml component using this code. But,
Sailfish should have already created its own instance of that page
when it started up.<br>
<br>
You might instead try retrieving a view of the Sailfish instance
and going from there, something like this:<br>
<br>
QQuickView *view = SailfishApp::createView();<br>
QObject *object = view->rootObject();<br>
QObject *label = object->findChild<QObject *>("label");<br>
<br>
--John<br>
<br>
On 8/13/15 10:51 AM, Antonio Mancini wrote:<br>
</div>
<blockquote
cite="mid:CAAX4RD7j+2YS4mhtLtMPd=j91E7Z6JO3USmwstmKqG9Gtj8oCg@mail.gmail.com"
type="cite">
<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
moz-do-not-send="true" 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 moz-do-not-send="true"><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 moz-do-not-send="true"><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 moz-do-not-send="true"><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 moz-do-not-send="true"><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 moz-do-not-send="true"
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 moz-do-not-send="true"
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
moz-do-not-send="true"
href="mailto:ziobilly94@gmail.com"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:ziobilly94@gmail.com">ziobilly94@gmail.com</a></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
moz-do-not-send="true"
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
moz-do-not-send="true"
href="mailto:devel-unsubscribe@lists.sailfishos.org"
target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a></a><br>
</blockquote>
</div>
<br>
</div>
<br>
_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a
moz-do-not-send="true"
href="mailto:devel-unsubscribe@lists.sailfishos.org"><a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a></a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a></pre>
</blockquote>
<br>
</body>
</html>