Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How does List allocate space using a custom structure in QML?
Forum Updated to NodeBB v4.3 + New Features

How does List allocate space using a custom structure in QML?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 308 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mirro
    wrote on last edited by mirro
    #1

    property var keyValueList[KeyValue{},KeyValue{}] //Error Code

    class KeyValue : public QObject
    {
      Q_OBJECT
      Q_PROPERTY(QString key READ getKey WRITE setKey NOTIFY keyChanged)
      Q_PROPERTY(QString value READ getValue WRITE setValue NOTIFY valueChanged)
    
     public:
      KeyValue(const QString& key, const QString& value, QObject* parent = 0);  
    
     signals:
      void keyChanged();
      void valueChanged();
    
     private:
      QString _key;
      QString _value;
    
      QString getKey() const;
      QString getValue() const;
    
      void setKey(const QString& key);  
      void setValue(const QString& value);
    };
    Q_DECLARE_METATYPE(KeyValue*)
    
    qmlRegisterType<KeyValue>("customqml", 1, 0, "KeyValue");
    
    import QtQuick 2.7
    import customqml 1.0
    
    Item{
      KeyValue {
        id: idKeyValue 
      }
      property var keyValueList[KeyValue{},KeyValue{}] //***Error Code***
    }
    
    1 Reply Last reply
    0
    • sierdzioS sierdzio

      Is there any question you want to ask?

      property var keyValueList[KeyValue{},KeyValue{}] //***Error Code***
      

      This is simply invalid syntax in QML. But I don't know what you want to achieve - without more info I can't help more.

      M Offline
      M Offline
      mirro
      wrote on last edited by mirro
      #3

      @sierdzio

      I just tested that the specified type needs to be stored in list
      Like this,
      property list<KeyValue> rects: [
      KeyValue{},
      KeyValue{}
      ]

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        Is there any question you want to ask?

        property var keyValueList[KeyValue{},KeyValue{}] //***Error Code***
        

        This is simply invalid syntax in QML. But I don't know what you want to achieve - without more info I can't help more.

        (Z(:^

        M 1 Reply Last reply
        0
        • sierdzioS sierdzio

          Is there any question you want to ask?

          property var keyValueList[KeyValue{},KeyValue{}] //***Error Code***
          

          This is simply invalid syntax in QML. But I don't know what you want to achieve - without more info I can't help more.

          M Offline
          M Offline
          mirro
          wrote on last edited by mirro
          #3

          @sierdzio

          I just tested that the specified type needs to be stored in list
          Like this,
          property list<KeyValue> rects: [
          KeyValue{},
          KeyValue{}
          ]

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved