如何知道基于项目的ListView QT C 中是否存在字符串
How to know if a string exist in a item based ListView Qt C++
我想知道在列表中的任何一项中是否存在一个字符串,c with qt,如何做?
也许这个小的迭代函数可以做到您要寻找的东西:
bool doesContain(QListView *listView, QString expression)
{
QAbstractItemModel* model = listView->model() ;
int rowCount = model->rowCount();
int columnCount = model->columnCount();
for(int i = 0; i < rowCount; i++)
for(int j = 0; j < columnCount; j++)
if(model->index(i, j).data(Qt::DisplayRole).toString().contains(expression))
return true;
return false;
}
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用Qt C++计算类似Git的SHA1哈希
- Qt focusObjectChanged example?
- QT QML ListView布局未调整大小
- Qt ListView 不显示C++模型内容
- Qt/QML:将 WebEngineView 放在 ListView 中并调用 loadHtml()
- 如何知道基于项目的ListView QT C 中是否存在字符串
- 如何使用文本文件中的内容填充Qt ListView
- Qt-将文件拖放到ListView中
- Qt QItemDelegate提交数据并在鼠标上关闭编辑器,离开视图小部件(listView)
- 在Qt中,我如何从模型中重置ListView中项目的背景颜色