Results 1 to 2 of 2

Thread: Accessing single items from QAbstractListModel in QML

  1. #1
    Join Date
    Dec 2018
    Qt products

    Default Accessing single items from QAbstractListModel in QML


    I have a c++ class derived from QAbstractListModel which I use as my Datamodel for QML.
    It has hundrets of objects in it which I want to access directly in QML.
    Using the whole model e.g. in a list ist working.

    Qt Code:
    1. ListView {
    2. width: 100; height: 800
    4. model: dataSourceModelObject
    5. delegate: Text { text: name + " " + value}
    6. }
    To copy to clipboard, switch view to plain text mode 

    But I want to access single objects of this ListModel by the ID of the object. Is this possible?


  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Accessing single items from QAbstractListModel in QML

    What are these objects that your model is interfacing with?

    Are they accessible from QML, i.e using Q_OBJECT or Q_GADGET for defining properties?


Similar Threads

  1. Replies: 8
    Last Post: 11th March 2016, 09:56
  2. Replies: 6
    Last Post: 30th December 2010, 11:19
  3. Replies: 3
    Last Post: 19th November 2010, 16:17
  4. Replies: 1
    Last Post: 15th May 2010, 18:22
  5. insertion of multiple items in a single row
    By grimbaum in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2006, 05:36


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.