Results 1 to 10 of 10

Thread: Display data from XML file in TableView

Threaded View

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

    Default Re: Display data from XML file in TableView

    Here
    Qt Code:
    1. std::vector<DataObject> mydata;
    To copy to clipboard, switch view to plain text mode 
    you are using DataObject as a value type, meaning you are working with copies when adding to or reading from the vector.

    But DataObject is a QObject dervied class, instances of QObject cannot be copied.
    You don't need the model's data clas to be derived from QObject, it is never directly exposed to QML.

    Aside from that:
    - you need a list model not a table model, as QtQuick only works on list models
    - you need to overwrite the model's rolesNames() method to provide a mapping from QML role names to your role enum values.
    - your MyXML method will want to work on the model that you expose to QML, not on newly created instances that get deleted at the end of the method

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    neda (24th February 2016)

Similar Threads

  1. How to export data in tableview to an excel file?
    By drunknight in forum Qt Programming
    Replies: 2
    Last Post: 31st December 2013, 03:39
  2. Preventing display spinbox in tableview cells
    By alizadeh91 in forum Qt Programming
    Replies: 2
    Last Post: 30th December 2012, 12:48
  3. display custom widget in a TableView
    By code_talker in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2012, 22:40
  4. TableView/Model Display Question
    By SixDegrees in forum Qt Programming
    Replies: 9
    Last Post: 27th August 2010, 10:06
  5. getting data from tableView
    By mkarakaplan in forum Newbie
    Replies: 1
    Last Post: 7th November 2007, 10:51

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
  •  
Qt is a trademark of The Qt Company.