Answer the question
In order to leave comments, you need to log in
How to create a QML object displaying the properties of a C++ object?
Those. Let's say we have a spaceship object in the game. All manipulations with it (including creation and deletion) are performed on the C++ side. QML is only required to draw it on the stage according to the current properties. How can this be implemented? The main problem is to create a QML object at the same time as a C++ object and at the same time ensure that the properties of the correct C++ object are displayed.
Answer the question
In order to leave comments, you need to log in
It is done quite simply:
Qt allows you to create QML from a string:
var newObject = Qt.createQmlObject(
'import QtQuick 1.0;Rectangle {color: "red"; width: 20; height: 20}',
parentItem, "dynamicSnippet1");
doc.qt.io/qt-4.8/qdeclarativedynamicobjects.htmlDidn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question