Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-25194

Passing a QPoint through a QVariantList cannot be accessed in QML

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 4.8.0
    • None
    • PC Ubuntu 11.10

    Description

      I create a QPoint that I embed in a QVariantList.
      From QML, the QPoint cannot be accessed whereas it can be accessed when provided as a QVariant:

          Q_INVOKABLE QPoint test() {
              return QPoint(5,6);
          }
      
          Q_INVOKABLE QVariant test2() {
              return QVariant(QPoint(5,6));
          }
      
          Q_INVOKABLE QVariantList test3() {
              QVariantList list;
              list.append(QVariant(5));
              list.append(QVariant(QPoint(5,6)));
      
              return list;
          }
      

      In QML

      import QtQuick 1.1
      
      Rectangle {
          width: 360
          height: 360
          Text {
              text: qsTr("Hello World")
              anchors.centerIn: parent
          }
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  console.log("coordinate.test().x="+coordinate.test().x);
                  console.log("coordinate.test2().x="+coordinate.test2().x);
                  console.log("coordinate.test3()="+coordinate.test3());
                  console.log("coordinate.test3()[0]="+coordinate.test3()[0]);
                  console.log("coordinate.test3()[1]="+coordinate.test3()[1]);
                  console.log("coordinate.test3()[1].x="+coordinate.test3()[1].x);
              }
          }
      }
      

      gives the following output:

      coordinate.test().x=5
      coordinate.test2().x=5
      coordinate.test3()=5,QVariant(QPoint)
      coordinate.test3()[0]=5
      coordinate.test3()[1]=QVariant(QPoint)
      coordinate.test3()[1].x=undefined
      

      The complete project is in attachment.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            agroyer Anthony Groyer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes