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

Make it possible to use containered Q_GADGETS in QML

    XMLWordPrintable

Details

    • All

    Description

      Let's say we have next data objects in c++:

      struct Payment {
          Q_GADGET
          Q_PROPERTY(Type type MEMBER type)
          Q_PROPERTY(qint64 amount MEMBER amount)
          Q_PROPERTY(QString name MEMBER name)
      public:
          enum class Type {
              Cash,
              TransportCard,
              BankCard
          };
          Q_ENUM(Type)
          Type type = Type::Cash;
          qint64 amount;
          QString name;
      };
      
      struct Fare {
          Q_GADGET
          Q_PROPERTY(Type type MEMBER type)
          Q_PROPERTY(QVector<Payment> paymentOptions MEMBER paymentOptions)public:
          enum class Type {
              Unkonwn = -1,
              Fixed,
              MultiFixed,
              ZoneBased,
          };
          Q_ENUM(Type);    Type type;
          QVector<Payment> paymentOptions;
      }
      

      Idea is to use ContainerT<Q_GADGET class> in QML without model or explicitly convert it to QVariantList.

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              alexeym A M
              Votes:
              4 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes