I want to create a QTreeview with 2 columns. That is no problem so far. I made this with the following code:
QStandardItemModel *model = new QStandardItemModel(0,2);
ui->treeView->setModel(model);
Now I want to fill this TreeView. To do that I created a QStandardItem with 0 rows and 1 column.
QStandardItem *root = new QStandardItem(0,2);
After that I added data to this root item.
root->setText("name");
root->setData("value", 1);
At the end I am adding the model to a QTreeView
ui->treeView->setModel(model);
The problem is, that value is not displayed in the second column of the QTreeView. I am sure, that the reason is, that the second column of the model is not the same as the second column of the root item.
But how to solve this problem?