[Qt-interest] QAbstractItemModel edit process

Stephen Kelly steveire at gmail.com
Wed Apr 21 17:30:04 CEST 2010


Nikos Gerontidis wrote:

> Hello list,
> 
> I have subclassed the QAbstractItemModel class and reimplemented the
> setData and the other functions needed in order to make the model
> editable. I have created custom items and my model follows a tree
> structure and multiple columns.
> The problem is that when I edit my model for a given index for decoration
> prurposes, then this results to setting all columns with decoration flags
> enabled to
> be updated with the data given. To be more specific, I made an example
> post
> :
> *setData(model->index(1,4),QColor(Qt::blue),Qt::DecorationRole)*
> after updating this then also the data of model->*index(1,6)* are being
> updated.
> The above situation is not happening though when my model is being updated
> for the last column :
> *setData(model->**index(1,6)**,QColor(Qt::blue),Qt::DecorationRole)*
> *this does not result *to an update of *model->**index(1,4)*
> 
> Does the model updates all remaining indexes until model->columnCount() ;
> If yes how could I end this update in order to set my data correctly? Any
> ideas?

That depends on how you implemented setData. It sounds like you accidentally 
implemented it to change the color of all columns instead of just one.

> Thanks in advance..
> 




More information about the Qt-interest-old mailing list