PDA

View Full Version : Passing QML component to C++ function



mut
25th March 2016, 05:28
Hello

http://doc.qt.io/qt-4.8/qml-component.html

I have a Q_INVOKABLE C++ function which must receive one QML component as a parameter.
What should be the parameter type of the C++ function?
When inside the C++ function, how to access the individual properties of the QML component?

Any example?

Thanks;

Mut

anda_skoa
25th March 2016, 10:15
Do you mean a component or an object?

I.e. is the QML side a Component or e.g. a QQuickItem type?

Also: what do you need this for? Very often "accessing QML from C++" means there are better ways of achieving the same result

Cheers,
_

mut
25th March 2016, 16:00
Thanks for the reply.

The QML side is a Component.
I want to store the component or a pointer to it in my c++ class and later give it back to QML upon request.
I also wondering what should be the signature of second function i.e. the one which allow QML side to get the component?

Mut

anda_skoa
26th March 2016, 11:34
The C++ class for the QML Component type is QQmlComponent.

So a property of type QQmlComponent* should work.

Cheers,
_