creating QML object dynamically
Is there anyway for creating a QML object dynamically from the Qt code, without using the .qml file or JavaScripts?
5 replies
There is a possibility to build QQmlExtensionPlugin to define your qmlfiles and refenrece them.
Is it the pint you think about ?
http://doc-snapshot.qt-project.org/5.0/qqmlextensionplugin.html
There is the an example in the TimeExample in the QT5 sources.
I already have a qml file and i want to add this declarative item on that QML file and be able to change the property for that declarative item. How to do that?
Below is the code snippet
int main(int argc, char *argv[])
{
I already have a qml file and i want to add this declarative item on that QML file and be able to change the property for that declarative item. How to do that?
Below is the code snippetint main(int argc, char *argv[])
QApplication app(argc, argv); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String(“qml/example_2/main.qml”)); QObject *rootObjectA = viewer.rootObject(); rootObjectA->setProperty(“text1Text”,QVariant(“Change you text here…”)); viewer.showExpanded(); return app.exec(); }
{
Maybe I didn’t understand what you want to do…if you just want to change a property on rootObjectA, the code above is correct…
You must log in to post a reply. Not a member yet? Register here!
