Compiling with Qt 5.14 gives: "Unable to assign QJSValue to QVector<QPointF>" , was not in Qt 5.13
-
I was just updating the Qt version from Qt 5.13 to Qt 5.14. Everything works fine in Qt 5.13 but now after the upgrade I started to get this printout
qrc:/qml/Component.qml:24:9: Unable to assign QJSValue to QVector<QPointF>
And sure enough, the CustomQuickItem is no longer displayed on screen.
Example code:
Component.qml
Repeater { model: _cppdatamodel CustomQuickItem { .... positions: model.positions //<-Component.qml:24 where the error occurs in Qt 5.14.0 not Qt 5.13.0 .... } }
The data method in the DataModel
QVariant DataModel::data( const QModelIndex & index, int role ) const { if( ( index.row() < 0 ) || ( index.row() > rowCount() ) ) { return QVariant(); } auto dataVariant = m_variantList.at( index.row() ); switch( role ) { .... case PositionsRole: return QVariant::fromValue< QVector< QPointF > >( dataVariant.positions() ); default: return QVariant(); } }
DataVariant.h
namespace model { class DataVariant { Q_GADGET public: DataVariant(); .... QVector< QPointF > positions() const; ... }; } Q_DECLARE_METATYPE( QVector< QPointF > )
And CustomQuickItem.h
class CustomQuickItem : public QQuickItem { Q_OBJECT Q_PROPERTY( QVector< QPointF > positions MEMBER m_positions ); public: CustomQuickItem(); ~CustomQuickItem(); ... private: ... QVector< QPointF > m_positions; ...
Any ideas what has changed in Qt 5.14 that might cause this problem?
-
I've been trying to figure out from the release notes for Qt 5.14 what might have changed to cause this issue, but with no luck. I think it is strange that this worked fine in Qt 5.13 but does not work in Qt 5.14.
By changing the QVector<QPointF> to a QVariantList fixes this issue.
-
Provide a minimal, compilable example and create a bug report.
-
@Christian-Ehrlicher : I created a bug report https://bugreports.qt.io/browse/QTBUG-80916 with a minimal viable example.