[Qt-interest] FW: QAbstractItemModel: Hiding rows

Arnold Krille arnold at arnoldarts.de
Sat Jul 11 00:13:26 CEST 2009


Hi,

On Friday 10 July 2009 23:52:53 Eric Clark wrote:
> I am not real sure why Brad said you were wrong, but I can see how it would
> work with a Proxy model. And I do believe that for most cases the proxy
> model is probably the correct solution. However, for my case, we have come
> up with some other solutions due to the speed we need to have. I cannot
> call insert or remove rows during certain circumstances in my application
> because we need to be as fast as possible.

Actually my mentioning of removeRows/removeColums was only to point you to the 
concept. Unless you implement these functions in your model, they will do 
nothing.:-)

You could be faster if you have your list of real data and a (small) 
additional list of the rows that are hidden. QAbstractItemModel::rowCount() 
would then return data.size()-hidden-size().
And for accessing an item, the index i to access data would be index.row() + 
the number of items in "hidden" that are smaller then index.row().

> What Brad suggested is based on my view using the data internally. I could
> easily add a data role called VisibleRole or something and return a Boolean
> flag, true if visible, and false if hidden. Then the view could just hide
> the item or not create it at all. This is a great solution and probably the
> easiest solution as it only requires my model to return an extra role in
> its data function. No need for mapping of reordered indexes or anything.

My point is: If you use special roles in the model and therefor can only use 
it with a special view, why go through all the loops of the model-view-
concept? While it might be interesting to part the data from the gui, there is 
then no additional benefit from using Qts QAbstractItemModel- and 
QAbstractItemView-classes for this as all the standard-views will not react to 
your special features in the model.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090711/ca5dcd7d/attachment.bin 


More information about the Qt-interest-old mailing list