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

DelegateChooser stopped working with enums in QVariants

XMLWordPrintable

    • d00c76171de0c76794eb70a7284326332c0b3c66 (qt/qtdeclarative/dev) 159dfd19a742276a1f8f610d46a2a3e2ed3d99f6 (qt/qtdeclarative/6.2)

      I have a DelegateChooser als delegate and as roleValue I am using enums.
      As model I use a QAbstractItemModel and return QVariant::fromValue(enumValue); which the DelegateChooser should switch on. (see attached example project)
      In Qt 5.15 it is working fine, but in Qt 6 it doesn't show any delegates.
      Changing the enum class to a unscoped enum doesn't change anything either.
      if I return the enum as an int (via cast and/or by changing it to unscoped enum) it works again.

      In QQmlDelegateChoice::match:

      • m_value: QVariant(int, 0)
      • value: QVariant(TestModel::Type, "Info")

      Due to the recent QVariant changes this comparison always fails because they are different types. Perhaps QVariant should make an exception for enums?

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

            srutledg Shawn Rutledge
            mkrems Marcel Krems
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes