0

I was wondering what kind of data I can use to handle a dataChanged-signal in a QML ListModel. I found out that it has three arguments, two of which are QModelIndices and one is a QVariant(...).

So from the first two (which seems to be the same?) I can get the row, column (which is supposed to be 0), the model itself and uhm... stuff

But why do I get it twice? And what is the content of the third? It is not null, but I haven't found a property I could use to retrieve some useful data from it.

dtech
  • 47,916
  • 17
  • 112
  • 190
  • May I ask you why are you trying to handle this signal in QML ? – GrecKo Oct 05 '16 at 14:55
  • Aye, you might. I want to update the Groups of a DelegateModel when the DelegateModels original model changes. I found no way to do this automatically, so I need to handel the signals when something is addded or when a value is changed. But to be sure that my handling is correct, I need to know exactly what my data stands for. – derM - not here for BOT dreams Oct 05 '16 at 15:07
  • I used it here: http://stackoverflow.com/questions/39770958/how-to-add-elements-to-a-delegatemodelgroup-depending-on-a-property/39825932#39825932 – derM - not here for BOT dreams Oct 05 '16 at 15:11

1 Answers1

1

A ListModel implementsQAbstractItemModel, the dataChanged signal you are seeing is the one defined in this class : void QAbstractItemModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int> ())

The 2 first parameters tell us that all data between the first and second indexes are changed. The 3rd parameter is a list of roles where the data has changed, if the list is empty it means the data at all roles has potentially been changed.

In your case the first and second indexes are the same because only one row is changed at a time.

GrecKo
  • 6,615
  • 19
  • 23