QTreeWidgetItem 通过文本查找子项
QTreeWidgetItem find child by text
如何在QTreeWidgetitem中按文本查找项目?有没有QTreeWidget的findItem方法的类似物?
我相信
你正在寻找的是QTreeWidget中的递归搜索。为此,您必须使用 Qt::MatchContains | Qt::MatchRecursive
的组合作为标志。
因此,如果 pMyTreeWidget 是指向QTreeWidget
的指针,而 myText 是包含要搜索的文本的QString
,假设搜索必须在第 0 列上,则代码将如下所示:
QList<QTreeWidgetItem*> clist = pMyTreeWidget->findItems(myText, Qt::MatchContains|Qt::MatchRecursive, 0);
foreach(QTreeWidgetItem* item, clist)
{
qDebug() << item->text(0);
}
如果您的要求是匹配确切的文本,则可以使用Qt::MatchExactly|Qt::MatchRecursive
而不是Qt::MatchContains|Qt::MatchRecursive
相关文章:
- C++ 使用存储在动态数组中的文本文件中的数据查找模式
- 如何从文本文件中查找最常见的字母和出现次数?
- 在文本中查找半个单词"ABBA"的问题
- 在C++中查找文本中的模式
- 创建程序以从给定的.txt文件中查找文本,替换并计算单词
- 如何创建一个函数,该函数在文本中查找单词的匹配项,包括跳过
- 在大型 JSON 文件中查找文本
- 尝试在自定义 QT 创建器文本编辑器中创建查找和替换循环.我似乎无法设置光标位置
- 文本文件中的电话号码查找
- 如何在没有分隔符的大文本文件中查找所有字典单词
- C++查找文本和计数出现次数
- 在文本文件 C++ 中查找( ")
- Visual Studio,在(解决方案资源管理器的)某个筛选器内的所有文件中查找/替换文本
- 查找字符在标准输入文本中出现的次数
- 如何将文本(诗歌)拆分为行(字符串/字符[])并查找每个行的最后一个单词
- 文本处理以查找字符串的共存
- 查找文本文件中的行数,并使用此维度构造数据点
- 在Qt5/C++中向后查找文本文件(尾随文件)
- 如何在c++中查找文本文件中的特定单词?
- 查找文本"space"值(以像素为单位)