Results 1 to 8 of 8

Thread: Display data from QStandardItemModel in QTreeView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Display data from QStandardItemModel in QTreeView

    Hi, this is my first post to the forum. I have an application that queries for data on a network. Then populates a QStandardItemModel in the following fashion;

    Qt Code:
    1. QStandardItemItem * parentItem = model->invisibleRootItem();
    To copy to clipboard, switch view to plain text mode 

    I iterate over my data instantiating new child items to be added to the model.
    Qt Code:
    1. item->setData(QVariant("some data"));
    2. parentItem->setChild(row,column,item);
    To copy to clipboard, switch view to plain text mode 

    Now the data is in the model, I have gone through it and written the data back out to the console.

    Next I set the model in my treeview in this way;

    Qt Code:
    1. treeView->setModel(model);
    2. QStandardItem * parentItem = model->invisibleRootItem();
    3. QModelIndex index = parentItem->index();
    4. treeView->setRootIndex(index);
    5. QModelIndex currentIndex = model->index(0,0);
    6. treeVeiw->setCurrentIndex(currentIndex);
    7. treeView->setRootIndex(index);
    To copy to clipboard, switch view to plain text mode 

    When the application runs and I get to the page with the treeview display, I see the model column header labels but no data.

    I don't understand why I don't see the data, any assistance would be appreciated.

    thanks
    Last edited by wysota; 9th January 2007 at 15:45. Reason: missing [code] tags

Similar Threads

  1. Modify model data in QTreeView
    By YuriyRusinov in forum Qt Programming
    Replies: 6
    Last Post: 26th October 2006, 17:28
  2. can't do a QTreeView with a QStandardItemModel
    By Nuria in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2006, 00:41
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  4. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03
  5. Dynamic Data Display with OpenGL
    By showhand in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2006, 01:17

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.