Hello,

I need a little help getting a QTreeView to display some characters. Let me first say that I'm not a very good programmer and pretty new to QT.
I am trying to make a QTreeView which behaves like a multi-column QListView used to in qt3 (btw, why are columns no longer available in QListView? It doesn't seem necessary for the model/view-thing to remove them). My first question is just if this is basically correct. Here is my QTreeView code, I mostly pieced it together from examples:

Qt Code:
  1. #include <QtGui>
  2.  
  3. int main(int argc, char *argv[]){
  4.  
  5. QApplication app(argc, argv);
  6.  
  7. QTreeView *qtv = new QTreeView();
  8. qtv->setItemsExpandable(false);
  9. qtv->setRootIsDecorated(false);
  10. qtv->setUniformRowHeights(true);
  11. qtv->setSelectionBehavior(QAbstractItemView::SelectRows);
  12. qtv->setSelectionMode(QAbstractItemView::SingleSelection);
  13. qtv->setSortingEnabled(true);
  14. qtv->sortByColumn(0, Qt::AscendingOrder);
  15.  
  16. itemmodel->setHorizontalHeaderLabels(QStringList() << "First" << "Second" << "Third");
  17. for (int i = 0; i < 5; ++i)
  18. for (int j = 0; j < 3; ++j)
  19. itemmodel->setItem(i, j, new QStandardItem(QString("Row: ") + QString::number(i) + QString(", Column: ") + QString::number(j)));
  20.  
  21. qtv->setModel(itemmodel);
  22. qtv->show();
  23.  
  24. return app.exec();
  25. }
To copy to clipboard, switch view to plain text mode 

Now (though it might not be the proper or most efficient way to do it) this seems to do what I want it to. But when I put a string in like "Eléna" in the model using itemmodel->setItem(i, j, new QStandardItem(QString("Eléna"))), the treeview shows "Eléna" instead. If I access the text in the model using itemmodel->item(i,j)->text() it does show the correct text. I had this problem in qt3 as well, I just thought while I was learning qt4, I might as well get this out of the way too. So could someone please help me fix this?

Thanks,
bepaald