[Interest] Adding QML code from C++ at runtime

Alexander Syvak alexander.svk at gmail.com
Thu Dec 4 14:04:14 CET 2014


Hi,

here's the code attached to the e-mail.

In the method woman::add_hip() I need to add a button which refers to
existing QML objects in main.qml.

In main.cpp the context and window are set to a global variable which is
accessed in the method woman::add_hip().

However, after instantiating the button in the context (which is a global
variable) there're errors

<Unknown File>: QML Button: Cannot anchor to an item that isn't a parent or
sibling.

<Unknown File>: QML Button: Cannot anchor to an item that isn't a parent or
sibling.

<Unknown File>: Unable to assign QQuickWindowQmlImpl to QQuickItem


How to achieve valid referencing from a dynamically created component in
C++?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141204/2d803481/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: untitled1_runtime.zip
Type: application/zip
Size: 5730 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141204/2d803481/attachment.zip>


More information about the Interest mailing list