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

POD cannot used in QML

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7
    • Remote Objects
    • None

    Description

      eg. {{ POD Infomation(QString name, QDate date) }}  generate code as below

      class Infomation
      {
          Q_GADGET
      
          Q_PROPERTY(QString name READ name WRITE setName)
          Q_PROPERTY(QDate date READ date WRITE setDate)
      public:
          Infomation() : m_name(), m_date() {}
          explicit Infomation(QString name, QDate date) : m_name(name), m_date(date) {}
          QString name() const { return m_name; }
          void setName(QString name) { if (name != m_name) { m_name = name; } }
          QDate date() const { return m_date; }
          void setDate(QDate date) { if (date != m_date) { m_date = date; } }
      private:
          QString m_name;
          QDate m_date;
      };
      

      this should be a value type otherwise cannot used in QML

      https://doc.qt.io/qt-6/qtqml-cppintegration-definetypes.html#registering-value-types

      Attachments

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

        Activity

          People

            bstottle Brett Stottlemyer
            jiu shanheng jiu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes