I really need some help updating my QTreeView. I have been looking all over the forum for solutions but I couldn't find any that worked...

This is the code I got:
Qt Code:
  1. PlaylistModel* plm = NULL;
  2.  
  3. MainWindow::MainWindow()
  4. {
  5. setupUi(this);
  6. plm = new PlaylistModel(this);
  7. treeView->setModel(plm);
  8. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. extern Playlist* currentPlaylist;
  2.  
  3. QVariant PlaylistModel::data(const QModelIndex &index, int role) const
  4. {
  5. if(!index.isValid())
  6. return QVariant();
  7. if(index.row() >= currentPlaylist->size())
  8. return QVariant();
  9. if(role == Qt::DisplayRole)
  10. {
  11. Song* song = currentPlaylist->at(index.row());
  12. if(song)
  13. {
  14. std::cout << "Song found!" << std::endl;
  15. if(song->info)
  16. {
  17. std::cout << "Info found!" << std::endl;
  18. if(index.column() == 0)
  19. return "Title";
  20. else if(index.column() == 1)
  21. return "Artist";
  22. }
  23. }
  24. return "N/A";
  25. }
  26. else
  27. return QVariant();
  28. }
  29.  
  30. QVariant PlaylistModel::headerData(int section, Qt::Orientation orientation, int role) const
  31. {
  32. if(role != Qt::DisplayRole)
  33. return QVariant();
  34. if(orientation == Qt::Horizontal)
  35. return QString("Column %1").arg(section);
  36. else
  37. return QString("Row %1").arg(section);
  38. }
  39.  
  40. int PlaylistModel::rowCount(const QModelIndex &parent) const
  41. {
  42. return currentPlaylist->size();
  43. }
  44.  
  45. int PlaylistModel::columnCount(const QModelIndex &parent) const
  46. {
  47. return 2;
  48. }
  49.  
  50. void PlaylistModel::update()
  51. {
  52. QModelIndex topLeft = createIndex(0, 0);
  53. QModelIndex bottomRight = createIndex(currentPlaylist->size()-1, 1);
  54. dataChanged(topLeft, bottomRight);
  55. }
To copy to clipboard, switch view to plain text mode 

As you can see, the data is stored in currentPlaylist (the Playlist class is just a QList). But when I add data to the currentPlaylist, it doesn't show it on the treeView... But when I add data to the currentPlaylist before I construct the tableView and model, it does show the data!

So I have tried to make an update function. But that doesn't work either...

Thanks in advance,
Gillis