[Qt-interest] how to traverse through QStandardItemModel

Valeriy Portnyagin portnyagin at reksoft.ru
Mon Jun 21 17:18:09 CEST 2010


hello all,
I find the simple way for walking through all items in the 
QStandardItemModel, in instance, like this:
  - QList<QStandardItem*> model->getAllItems(). 
  - QList<QModelIndex> model->getAllItems().

I leant all function in this class but didn't find something convenient.
 there is an example with QFileSystemModel:

QFileSystemModel *model = new QFileSystemModel;
QModelIndex parentIndex = model->index(QDir::currentPath());
int numRows = model->rowCount(parentIndex);
for (int row = 0; row < numRows; ++row) {
        QModelIndex index = model->index(row, 0, parentIndex);
        QString text = model->data(index, Qt::DisplayRole).toString();
        // Display the text in a widget.
     }

I don't like such variant. 

So, how i understand i need my own function for the traverse my 
QStandardItemModel or i have missed something?

regards,
Valery Portnyagin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100621/61c4850c/attachment.html 


More information about the Qt-interest-old mailing list