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

QML: Subclassing a QQuickItem that has revisioned properties fails

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11, macOS
    • Commits:
      c3999f96536ac359ba94d80755230e85238d578a

      Description

      QQuickTableView has some properties with a revision, e.g:

      Q_PROPERTY(int topRow READ topRow NOTIFY topRowChanged REVISION(6, 0))
      

      But if you subclass QQuickTableView from outside Qt (e.g like we do in Qt for TreeView), those revisioned properties will not be available from QML. E.g, if you do:

      #include <QtQuick/private/qquicktableview_p.h>
      
      class TreeView : public QQuickTableView
      {
          Q_OBJECT
          QML_ELEMENT
      
      public:
          TreeView(QQuickItem *parent = nullptr)
              : QQuickTableView(parent)
          {}
      };
      

      ...and then use it:

      import QtQuick
      import QtQuick.Window
      import TreeView
      
      Window {
          width: 480
          height: 640
          visible: true
      
          TreeView {
              anchors.fill: parent
              model: 10
              rowSpacing: 1
              delegate: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 20
                  color: "green"
              }
      
              onTopRowChanged: print(topRow)
          }
      }
      

      You will get an error that says:

      qrc:/main.qml:20:9: "TreeView.onTopRowChanged" is not available in TreeView 6.0.
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              max.goldstein Maximilian Goldstein
              Reporter:
              richard Richard Moe Gustavsen
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews