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. Access QVector<type> from QML

Access QVector<type> from QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml qtquickqvector
3 Posts 2 Posters 901 Views
  • 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.
  • R Offline
    R Offline
    romain.donze
    wrote on last edited by
    #1

    Hi everyone,

    So in QtQuick, I have many QVector<T> with T being a normal class, for instance:

    class Person
    {
    public:
        Person();
    
        void setName(QString);
        void setAge(int);
        void setSize(float);
    
        QString getName();
        int getAge();
        float getSize();
    signals:
    public slots:
    private slots:
    private:
        QString name;
        int age;
        float size;
    }
    

    I would like to access those data from my QML. What would be the best way to do that? Concidering I could also have some QVector<T> with T being

    class Children : public Person
    {
    public:
        Children(Person *parent = nullptr);
    signals:
    public slots:
    private slots:
    private:
    }
    

    Thanks for advices and feedbacks

    raven-worxR 1 Reply Last reply
    0
    • R romain.donze

      Hi everyone,

      So in QtQuick, I have many QVector<T> with T being a normal class, for instance:

      class Person
      {
      public:
          Person();
      
          void setName(QString);
          void setAge(int);
          void setSize(float);
      
          QString getName();
          int getAge();
          float getSize();
      signals:
      public slots:
      private slots:
      private:
          QString name;
          int age;
          float size;
      }
      

      I would like to access those data from my QML. What would be the best way to do that? Concidering I could also have some QVector<T> with T being

      class Children : public Person
      {
      public:
          Children(Person *parent = nullptr);
      signals:
      public slots:
      private slots:
      private:
      }
      

      Thanks for advices and feedbacks

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @romain-donze
      Example:
      https://doc.qt.io/qt-5/qtqml-referenceexamples-properties-example.html

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      R 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @romain-donze
        Example:
        https://doc.qt.io/qt-5/qtqml-referenceexamples-properties-example.html

        R Offline
        R Offline
        romain.donze
        wrote on last edited by
        #3

        @raven-worx Thank you for this answer. In fact I already found this example but wouldn't this be a problem if my Person class is in a vector?

        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