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

ListView sections don't work with a dot syntax (e.g. "gadget.size") if using Q_GADGETs

    XMLWordPrintable

Details

    • Linux/Wayland, macOS, Windows

    Description

      Steps to reproduce:

      • Run the attached reproducer.

      What done in the reproducer:

      • Create a ListView (gadgetListView in the reproducer) in QML, which accesses QAbstractListModel defined in C++ (myGadgetList in the reproducer). 
      • Each entry of the QAbstractListModel is an instance of a class defined with Q_GADGET macro (MyGadget class in the reproducer).
      • Let the ListView to classify entries into sections automatically, depending on each entry's property (gadget.size), as follows:

              section

      {             property: "gadget.size"             criteria: ViewSection.FullString             delegate: sectionHeading         }
      • This section property (dot notation access : "gadget.size") does not work. The entries in myGadgetList are not classified in sections in the ListView.
      • The same approach works for myObjectList, a list of instances with Q_OBJECT macro.

      Side note:

      • The user is pointing out that this might be being caused by QQmlDelegateModelPrivate::variantValue(), where it seems assuming only Q_OBJECT, i.e. casting the entry to QObject pointer.
      • Besides ListView Sections, Qt 6.7.0 shows a bit different behvior than 6.6.x.
          The notation "object.size" and "gadget.name" work with 6.6.x, but not with 6.7.0, while "object.name" and "gadget.name" work with 6.0.x and 6.7.0 both.
          (See attached qt_6_6_2.png, qt_6_6_3.png and qt_6_7_0.png)

      Attachments

        1. listview_sections_qgadget_modified.zip
          4 kB
        2. qt_6_6_2.png
          qt_6_6_2.png
          24 kB
        3. qt_6_6_3.png
          qt_6_6_3.png
          25 kB
        4. qt_6_7_0.png
          qt_6_7_0.png
          20 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            hitoshiito Hitoshi Ito
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes