Results 1 to 2 of 2

Thread: How to access c++ vector in QML

  1. #1
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to access c++ vector in QML

    Hi,
    I am developing QT widget application and for one UI part i have used QML also.
    I am facing problems in using vector type in QML file.

    QT widget code:

    vector<controller> *vectorObj (Controller is class)

    controller *ob1=new controller();
    ob1->setName("GP");
    ob1->setId("2");

    controller *ob2=new controller();
    ob2->setName("PM");
    ob2->setId("5");

    vectorObj->push_back(ob1);
    vectorObj->push_back(ob2);

    Now vector is holding two objects of class Controller.

    QML File :

    Now in QML file i have two rows and each row has two columns.
    In row1 i want to display ob1.getName() and ob1.getID()
    and in row 2 i want to display ob2.getName and ob2.getID()

    I tried using QProperty but unable to get values.
    Might be i have used QProperty in some wrong way or if there is some other way to achieve same then please share.


    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to access c++ vector in QML

    Have you considered a table model with the vector as its data?

    Cheers,
    _

Similar Threads

  1. Copying vector of pointers to another vector
    By Momergil in forum Newbie
    Replies: 12
    Last Post: 24th September 2011, 22:09
  2. vector of vector and computes
    By mickey in forum General Programming
    Replies: 1
    Last Post: 15th May 2008, 12:47
  3. insert in a vector of vector
    By mickey in forum General Programming
    Replies: 3
    Last Post: 6th March 2007, 08:45
  4. vector of vector size
    By mickey in forum General Programming
    Replies: 5
    Last Post: 13th February 2007, 15:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.