从 QVariantList 获取字符串
Getting strings from QVariantList
来自我的数据库的数据在QVariantList中,我想遍历它并获取名字。
QVariantList sqlData = database->loadDatabase("quotes.db", "quotes");
for (int i = 1; i <= sqlData.size(); i++)
{
qDebug() << sqlData.value(i);
}
这会产生:
Debug: QVariant(QVariantMap, QMap(("firstname", QVariant(QString, "Glenford") ) ( "id" , QVariant(qlonglong, 2) ) ( "lastname" , QVariant(QString, "Myers") ) ( "quote" , QVariant(QString, "We try to solve the problem by rushing through the design process so that enough time will be left at the end of the project to uncover errors that were made because we rushed through the design process.") ) ) )
如何调试"名字"的值?例如调试 = 格伦福德。
谢谢
QVariant 列表是 QVariants 的列表,对象有一个特定的迭代器。
QVariantList sqlData = database->loadDatabase("quotes.db", "quotes");
for (QVariantList::iterator j = sqlData.begin(); j != sqlData.end(); j++)
{
qDebug() << "iterating through QVariantList ";
qDebug() << (*j).toString(); // Print QVariant
}
相关文章:
- 从C字符串中获取奇怪的字符串长度
- 获取字符串的长度并将其分配给数组
- 我如何获取从 C++ 到 C 的映射<字符串、int>#
- 调用CreateProcess()并获取字符串的返回值
- 从字符串中获取结构的大小
- Cryptopp:获取密码输入的填充字符串
- 获取无效的字符串大小
- 获取 OID(类型::b_oid)作为 MongoDB C++驱动程序中的字符串
- C ++编译器如何获取argv字符串的长度
- 给枚举一个整数,并在 C++ 中将其相关值作为字符串获取
- 如何使用字符串获取用户控制台输入
- 通过字符串获取小部件
- 无法从字符串获取数字输入
- 在C++的静态方法中将类名作为字符串获取
- 从设备实例路径字符串获取设备实例 DWORD
- HRESULT到字符串(获取文档路径)C++
- 如何从http请求体字符串获取文件名
- 如何使用带有垃圾字符的子字符串获取字符串
- 通过字符串获取对话框项的可能性
- 有没有办法将 WinAPI 错误标志作为字符串获取