Create a new QObject from QML scripts
-
Greetings,
I would like to do something like this from my QML script:
@onPressed: {
var item = new myQObject;
}@
I did the following in C++:
@qmlRegisterType<MyQObject>("Module", 1,0, "myQObject");@
Have I missed something ? -
I think you should use something like:
@onPressed: {
Loader {
id: myLoader
MyQObject {
...
}
}@but of course use a capital letter for MyObject
-
I suggest you also to read this useful "doc":http://developer.qt.nokia.com/doc/qt-4.7/qtbinding.html, it has been useful for me :)
-
Hi,
The syntax you've shown isn't currently supported, but there are a few different ways to deal with dynamic objects in QML -- http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html provides an overview.
Regards,
Michael -
Thanks guys.
B.A.