C++ Struct in QML. How?
-
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.
-
@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
-
@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.