[Qt-interest] dataChanged() SIGNAL in proxy models

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Thu Jul 1 11:33:35 CEST 2010


>> I have a QStringListModel on which I have applied my proxy model to
>> return the data in a tabular manner (rows/cols).
>
> I would say it's a better idea to write your own table model instead of
> trying to turn a list into a table. Adding extra columns by using a proxy
> model is a bad idea and will likely cause QPersistentModelIndexes to become
> corrupted.

I'm actually not adding extra columns to the list model. It's rows in
the list which get transformed into columns in the table model.

eg: if list model has 5 rows (and 1 column) and the table dimension is
set to 3X3, then I will proxy the data such that the table proxy
returns 2 rows as rowcount and 3 columns column count.

List = 1,2,3,4,5

Table:
1,2,3
4,5

The reason I'm doing this is because the source of the data is
returning a list but the display has to be tabular (I could still
extract the list data and populate a table model, but I though this
might turn out to be easier).

I agree that QPersistentModelIndexes might get corrupted, but there's
no requirement to hold/store the model indexes persistently. (the data
from the source is pretty dynamic).

>
>>
>  const QModelIndex proxyBottom = mapFromSource(sourceBottomRight);
>  const QModelIndex proxyBotttomRight =
> proxyBottom.sibling(proxyBottom.row(), proxyBottom.column() +
> number_of_extra_columns);

I don't understand, why is this needed?

Thanks,
-mandeep

>
>  emit dataChanged(proxyTopLeft, proxyBottomRight);
> }




More information about the Qt-interest-old mailing list