• 9888阅读
  • 5回复

怎样通过循环来遍历QListView 中的项目呢? [复制链接]

上一主题 下一主题
离线robertkun
 

只看楼主 正序阅读 楼主  发表于: 2009-06-20
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
请教一下 :
怎样通过循环来遍历QListView 中的项目呢?

我在 QListView 加入了n个 QStandardItemModel 不知道怎样实现遍历,找出其中名字为空的项目。。
                                              简单的生活使人快乐!
离线robertkun

只看该作者 5楼 发表于: 2009-06-23
好~~
                                              简单的生活使人快乐!
离线318065268
只看该作者 4楼 发表于: 2009-06-22
可以查查foreach的用法,比这个要简便
Email  rsail@126.com(私人邮箱)
QQ:   318065268
离线robertkun

只看该作者 3楼 发表于: 2009-06-21
谢谢了,
我现在用这个方法

    //yangnew 20090620s **判断边框名称是否为空格**
     for(int i=0;i<mIndex-1;i++)  //mIndex 是用来保存我加入项目的个数。。
     {
        QModelIndex Index = mListViewModel->index(i, 0);
         QStandardItem* item = mListViewModel->itemFromIndex(Index);

         if(item->text()=="")
         {
             item->setText(mBordreText);  //如果为空格则重置为原来的值
         }
     }
    //end
                                              简单的生活使人快乐!
离线feiying888

只看该作者 2楼 发表于: 2009-06-21
QList<QStandardItem *> QStandardItemModel::findItems ( const QString & text, Qt::MatchFlags flags = Qt::MatchExactly, int column = 0 ) const

Returns a list of items that match the given text, using the given flags, in the given column.
离线feiying888

只看该作者 1楼 发表于: 2009-06-21
QList<QStandardItem *> QStandardItemModel::findItems ( const QString & text, Qt::MatchFlags flags = Qt::MatchExactly, int column = 0 ) const

Returns a list of items that match the given text, using the given flags, in the given column.
快速回复
限100 字节
 
上一个 下一个