Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Compiling with Qt 5.14 gives: "Unable to assign QJSValue to QVector<QPointF>" , was not in Qt 5.13
QtWS25 Last Chance

Compiling with Qt 5.14 gives: "Unable to assign QJSValue to QVector<QPointF>" , was not in Qt 5.13

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlqtquickqjsvalueqt5.14qt.5.13
4 Posts 2 Posters 929 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    plover
    wrote on last edited by plover
    #1

    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?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      plover
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Provide a minimal, compilable example and create a bug report.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        P 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          Provide a minimal, compilable example and create a bug report.

          P Offline
          P Offline
          plover
          wrote on last edited by
          #4

          @Christian-Ehrlicher : I created a bug report https://bugreports.qt.io/browse/QTBUG-80916 with a minimal viable example.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved