QVector or std::vector to qml
-
Hi,
I'm developing an app where I must pass some data stored in vector (QVector or std::vector, I dont care) to qml.
I have been looking in Google how to do this but there's is a lot of non clear information and I'm new to QML so its hard for me to understand it.
My class has a property of this type:
Q_PROPERTY(QVector<float> distance READ distance NOTIFY distanceChanged)
So my question is, how can I pass a property like that to QML?
I'm using Qt 5.7Thanks!
-
Hi! For an in-depth explanation see Exposing Attributes of C++ Types to QML.
QVector<float>
to QML is not supported transparently, insteadQVariantList
is used. More info can be found in Sequence Type to JavaScript Array. -
Thanks Wieland!
I'm studying the QML documentation :-)
-
@Wieland said in QVector or std::vector to qml:
QVector<float> to QML is not supported transparently
in Sequence Type to JavaScript Array:
In particular, QML currently supports: [...] QVector<qreal>
So it might be natively supported (if you configured qt to use float, which is unusual) or is pretty close to be natively supported if you are open to switch to double precision floating points instead