I have a model-view set up and so far, they appear synchronized. Now my problem appears when I am trying to change the text in one of the QTreeView leaves.
Given a QModelIndex, I can change the leaf's color using something like:
QAbstractItemModel *Model
= const_cast<QAbstractItemModel
*>
(Current_Model_Index
->model
());
Model->setData(*Current_Model_Index,Qt::blue,Qt::TextColorRole);
QAbstractItemModel *Model = const_cast<QAbstractItemModel*>(Current_Model_Index->model());
Model->setData(*Current_Model_Index,Qt::blue,Qt::TextColorRole);
To copy to clipboard, switch view to plain text mode
Similarly, I attempted to change the value of the text using this:
Model->setData(*Current_Model_Index,tr("XXXXXXX"),Qt::DisplayRole);
Model->setData(*Current_Model_Index,tr("XXXXXXX"),Qt::DisplayRole);
To copy to clipboard, switch view to plain text mode
That did not work. So I checked: Model->data(*Current_Model_Index,Qt::ItemIsEditable).toB ool() and this returned false.
I tried to change this property to true but it would not hold (the values was not retained when checked). How can I achieve my goal of assigning a text value to a tree leaf given its QModelIndex?
Bookmarks