Results 1 to 3 of 3

Thread: Could anyone show me the Model

  1. #1
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Could anyone show me the Model

    Hi! Can anyone show me the example of model which should work with reading from xml file:
    for exaple, my app reads one xml file and need to insert the data to the model...

    How can I do it?

    Thanks for advices! (Documentation I've read) but there is one problem - xml parser and wodel - how to connect?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Could anyone show me the Model

    You don't have to "insert" anything into a model. The xml file can be a model... You ask for an example... I can't give you an example of a complete model, this is your job. I can give you a hint -- use DOM (QDomDocument and family) to parse xml file and provide data for your model. Another hint would be to state, that probably internal pointers that come in idexes should point to appropriate QDomElements.

  3. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Could anyone show me the Model

    Quote Originally Posted by wysota
    You don't have to "insert" anything into a model. The xml file can be a model... You ask for an example... I can't give you an example of a complete model, this is your job. I can give you a hint -- use DOM (QDomDocument and family) to parse xml file and provide data for your model. Another hint would be to state, that probably internal pointers that come in idexes should point to appropriate QDomElements.
    That's easier said than done. See here : http://lists.trolltech.com/qt4-previ...ad00810-0.html

    You may find that you will have to parse the XML file with QDomDocument and create your own persistant tree structure to store the data that you read for your model. You can then safely have your model indexes point to items in this data structure.

    [EDIT]
    Alternatively, as you load your QDomDocument, store all the data in a QStandardItemModel. I think this option would be easiest to implement, since you wont have to worry about using QModelIndexes at all.
    Last edited by Chicken Blood Machine; 18th March 2006 at 01:15.
    Save yourself some pain. Learn C++ before learning Qt.

Similar Threads

  1. Replies: 1
    Last Post: 23rd November 2008, 14:11
  2. [+] does not show up immediately
    By yuriry in forum Qt Programming
    Replies: 4
    Last Post: 4th October 2008, 19:14
  3. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 16:26
  4. Something fishy about Model, data doesn't show up!
    By zlosynus in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2008, 15:07
  5. Model, view, resize to show all data
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2006, 20: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.