Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to create an Item from C++ (without QML?)

$
0
0
You can use existing QDeclarativeItem classes as for instance QDeclarativeMouseArea just like any other by including the header (QtDeclarative/private/qdeclarativemousearea_p.h) and exporting the class to the declarative library (you do not have to, and even cannot, use the meta type system as the items beeing a QObject are non-copyable and therefore non-constructible). Be aware that this will void any binary compatibility promises (although the QDeclarativeItem classes are very unlikely to change now). But maybe you do not even need to do that. What is your initial requirement? Why don’t you use QML to declare your item in the first place? What about a global ComponentFactory which is initialized with the QDeclarativeEngine once and used to create components from basically anywhere in your code?

Viewing all articles
Browse latest Browse all 4972

Trending Articles