Subclassing QQuickItem and Connections between them
-
Hi,
so I got the following situation, which I don't really know how to solve:
I got a C++ class that subclasses QQuickItem. And I got another class which provides data for this class to display.
I thought about connecting both classes with signals and slots so they can exchange control information and data.
Up until now I only had static data in my QQuickItem subclassed class, so I could make it available in QML via qmlRegisterType. Now that I want to receive dynamic data I encountered the same problem this user had:
http://qt-project.org/forums/viewthread/744
He apparently solved it by using setContextProperty(). I also tried this but I can't figure out how to make the object appear on the screen in my Quick Application.
So up until now it worked like this:
cpp:
@qmlRegisterType("Object", 1, 0, "class")@
qml:
@import Obejct 1.0
class { ... }@If I do this now via
cpp:
@viewer.rootContext()->setContextProperty("Class", &class);@
it will tell me: class is not a typeIs there a special way to make QQuickItem subclasses objects known to QML or is this maybe only possible via qmlRegisterType?
Also if someone has other solutions for that problem I'd be happy to hear them. Thanks.