Results 1 to 2 of 2

Thread: Qt Kinetic: adding items to list

  1. #1
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt Kinetic: adding items to list

    I'm trying to make program which uses Qt Kinetic Declarative UI: http://labs.trolltech.com/blogs/2009...eclarative-ui/

    I've been trying to add items to ListView from C++ but it doesn't work. Static QML ListModel works just fine. I can't find the API online but it says you can pass C++ data models to QML.

    • QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
    • QStringList provides the contents of the list via the modelData role.
    • QList<QObject*> provides the properties of the objects in the list as roles.


    For example how do I make this model in C++ so I can add new elements in C++?

    Qt Code:
    1. ListModel {
    2. id: ContactModel
    3. ListElement {
    4. name: "Bill Smith"
    5. number: "555 3264"
    6. }
    7. ListElement {
    8. name: "John Brown"
    9. number: "555 8426"
    10. }
    11. ListElement {
    12. name: "Sam Wise"
    13. number: "555 0473"
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt Declarative UI: adding items to list

    Any ideas? I have tried different solutions but nothing works.

Similar Threads

  1. Replies: 5
    Last Post: 17th February 2009, 05:35
  2. Replies: 1
    Last Post: 15th January 2009, 11:34
  3. Adding items to a QGraphicsScene's selection list?
    By mooreaa in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2008, 21:01
  4. multiple selection of list view items
    By samirg in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 20:05
  5. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 21:04

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.