[Qt-interest] how to traverse through QStandardItemModel

Malyushytsky, Alex alex at wai.com
Mon Jun 21 23:28:31 CEST 2010


What is wrong with using
QStandardItem * QStandardItemModel::item ( int row, int column = 0 ) const
in nested loops - by row and column?

Alex


From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Valeriy Portnyagin
Sent: Monday, June 21, 2010 8:18 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] how to traverse through QStandardItemModel

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.


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list