Important: Please read the Qt Code of Conduct -

To access QList<QPointF> property value in cpp side using qmetaProperty

  • I have defined a class using QObject and defined a property in it using Q_PROPERTY of type QList<QPointF>. I can access this property in QML side. But by using the object pointer, if i try to read the property value using qmetaproperty, i gets the value as QVariant(QList<QPointF>, ) like an empty list rather than actual value list.

    cpp side:

    class ExampleObj
    Q_PROPERTY(QList<QPointF> prop READ prop WRITE setProp NOTIFY propChanged)
    QList<QPointF> prop() {
    QPointF p (1,2);
    QList<QPointF> pointL;
    pointL << p << p << p;
    return point L;



    QML side:

    // I can access the 'prop' values, and modify them in QML side

    Cpp side:

    QQuickItem *obj = qobject_cast<QQuickItem *>(qmlExampleObj.value<QObject *>());
    const QMetaObject *meta_object = obj->metaObject();
    const QMetaProperty meta_property = meta_object->property("prop");
    qDebug() <<;
    // output: QVariant(QList<QPointF>, )
    //But expecting output as QVariant(QList<QPointF>, (QPointF(1,2), QPointF(1,2), QPointF(1,2)))

    Could you please guide me if i missed anything here ?. Thanks

Log in to reply