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 to use Q_PROPERTY with an array?
Forum Updated to NodeBB v4.3 + New Features

How to use Q_PROPERTY with an array?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.4k Views 2 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.
  • E Offline
    E Offline
    eoreyg
    wrote on 2 Dec 2020, 11:35 last edited by
    #1

    Hi, I'm having a trouble in use of Q_PROPERTY. Firstly my aim is defining property in QML side. I want to use it as following form:

    class Parameters : public QObject
    {
              Q_OBJECT
        public:
              Parameters(){}
              float Param1[13];
              int Param2[5];
              int Param3
              /*  various 
                 parameters  */
              Q_PROPERTY(float Param3_ MEMBER Param3)          //there is no problem. I can also access in the qml side.
              Q_PROPERTY(float Param1_ MEMBER Para1)             // How can I use this with array. This the line I had trouble.
    

    Instead of defining these parameters as member, I tried to define them in a struct as struct will be the member of this class.
    But I couldn't use the struct with Q_PROPERTY to access this members in qml side.

    How can I handle with this problem. I'm open to these two ways.

    Thanks in advance!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 2 Dec 2020, 14:21 last edited by
      #2
      float Param1[13];
      MEMBER Para1
      

      Names do not match :-)

      I don't think arrays are supported by QML engine. Use QList, QVariantList or a similar construct instead.

      (Z(:^

      1 Reply Last reply
      2
      • E Offline
        E Offline
        eoreyg
        wrote on 2 Dec 2020, 14:26 last edited by
        #3

        It works when I use QVector. It didn't come my mind :) Thanks a lot :)

        1 Reply Last reply
        0

        1/3

        2 Dec 2020, 11:35

        • Login

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