[Qt-interest] Model Index Iteration

Andre Somers andre at familiesomers.nl
Fri Nov 26 08:12:20 CET 2010


Op 26-11-2010 3:28, Scott Aron Bloom schreef:
> If you have the model...
>
> Just do something like
> For( int row = 0; row<  model->rowCount( parentIdx ); ++row )
> {
>     For( int col = 0; col<  model->columnCount( parentIdx ); ++col )
>     {
>          QModelIndx idx = model->index( row, column, parentIdx );
>          .....
>     }
> }
Don't forget to iterate over child items as well, if your model is 
tree-shaped...

André

>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Jake Colman
> Sent: Thursday, November 25, 2010 6:13 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Model Index Iteration
>
>
> I have a QComboBox with a derived QStandardItemModel.  I need to iterate
> over the entire model in order to reset a property on each item.  I've
> gone through the docs but cannot figure it out.  Given that I have a
> QAbstractItemModel* (actually a pointer to my derived type, of course)
> how do I iterate the entire model and gain access to each item?  A code
> snipper would be really helpful!
>
> Thanks.
>
> ...Jake
>
>




More information about the Qt-interest-old mailing list