C++ Struct in QML. How?
-
wrote on 3 Jan 2020, 12:50 last edited by
Hello all!
I need to pass some structured data from QML into C++ and vice versa.What is the best way for it:
- Via QVariantMap and transform it at time of appearing in C++ into struct by hand in function or in opposite direction into map from struct?
- Declaring struct meta information in Qt Engine and use struct directly in QML? Something like this.
Is there information about performance, maintenance, advantage or disadvantage etc?
-
Use model instead.
-
The answer provided on the thread will work nicely and you won't have to do the conversions yourself.
As for performance, do your own benchmark because it will depend on your use case and what you do with your structure.
As for @kuzulis suggestion, it refers to the the model/view paradigm. It's also a possible good solution but will depend on your particular use case.
-
The answer provided on the thread will work nicely and you won't have to do the conversions yourself.
As for performance, do your own benchmark because it will depend on your use case and what you do with your structure.
As for @kuzulis suggestion, it refers to the the model/view paradigm. It's also a possible good solution but will depend on your particular use case.
wrote on 3 Jan 2020, 14:50 last edited by bogong 1 Mar 2020, 14:51@SGaist You sending me the link that posted by me from begin? Why? What about vice versa??? How the model might be related to the matter of using in QML??? the question is about using struct but not any other solution.
-
wrote on 3 Jan 2020, 14:54 last edited by
@bogong said in C++ Struct in QML. How?:
related ???
https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html
-
@bogong said in C++ Struct in QML. How?:
related ???
https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html
wrote on 3 Jan 2020, 14:56 last edited by@LeLev Again - the question is about USING STRUCT
-
wrote on 3 Jan 2020, 16:00 last edited by
@bogong said in C++ Struct in QML. How?:
USING STRUC
The reply is: it is NOT possible ==> Overview - QML and C++ Integration
To provide some C++ data or functionality to QML, it must be made available from a QObject-derived class.
1/8