c++ - 搜索 QV​​ariantList?

标签 c++ qt

我在 QVariantList 中有一个 SKU(SKU - 库存单位)列表。

有没有办法搜索列表并从列表中获取数据?

例如,我想在列表中搜索“sku 0001”并获取 SKU 的关联标题。

谢谢

最佳答案

使用来自 <QtAlgorithms> 的 qFind

例如:

QVariantList vl;
vl << 42 <<"hello"<<3.1415;
QVariantList::const_iterator v = qFind(vl,42);
int iv = (*v).toInt();
++v;
QString sv = (*v).toString();

关于c++ - 搜索 QV​​ariantList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14083134/

相关文章:

c++ - Electron :ui和后端进程在Windows上访问相同的日志文件

c++ - 我如何将 Octave (matlab 克隆)与 qt creator 集成

c++ - 使用 QVector 的内存泄漏

c++ - QT中QByteArray和QByte Stream如何释放内存

c++ - 无法获取 bool 值以返回 false C++

使用模板元编程的 C++ 数值解析器

qt - QML:上标/下标文本

android - 启动 Qt/QML android 应用程序时如何立即显示启动画面?

qt - QML 鼠标区域 : onExited doesn't trigger after programmatically moving mouse into MouseArea

c++ - 为什么这不会在接受输入后循环退出