Hi

I wanna switch from item-based QTreeWidget to model/view QTreeView.
I have a 3-column-model. I need to display model-column 0 as Qt::UserRole of view-column 0, model-column 1 as Qt:isplayRole of view-column 0 and model-column 2 as Qt:isplayRole of view-column 1.

Before in the treewidget i did it like this:
Qt Code:
  1. item->setData(0, Qt::UserRole, index.column(0).toString());
  2. item->setData(0, Qt::DisplayRole, index.column(1).toString());
  3. item->setData(1, Qt::DisplayRole, index.column(2).toString());
To copy to clipboard, switch view to plain text mode 

The model is build like this:

Qt Code:
  1. void myLessonNotesModel::refresh()
  2. {
  3. setQuery("SELECT noteid, date, content FROM note ORDER BY date DESC");
  4. setHeaderData(0, Qt::Horizontal, QObject::tr("Datum"));
  5. setHeaderData(1, Qt::Horizontal, QObject::tr("Notiz"));
  6. }
To copy to clipboard, switch view to plain text mode 

Can anybody tell me how to connect the model columns to different view columns in different roles?

Best regards
Felix