我有一个像{"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}
现在我想如何分割字符串并在qml中显示列表视图,如下所示
注册成功
Empid = 157
TableName = COMPANY156
请告诉概念拆分字符串并在qml中显示结果
我可以获得以下方法的结果:{"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}
但我不知道如何分割字符串..请帮助..
答案 0 :(得分:3)
最后我通过参考文档获得了解决方案
http://developer.blackberry.com/native/reference/cascades/qstring.html#details
第1步:
在 cpp 标题#include <QStringList>
第2步:
JsonDataAccess jda;
QVariantMap map = jda.loadFromBuffer(reply->readAll()).toMap();
QVariantList addresses = map["RegistrationResult"].toList();
qDebug() << "RegistrationResult is "<<map["RegistrationResult"].toString();
QString result;
QString empid;
QString empid_no;
QString companyname;
QString::SectionFlag flag = QString::SectionSkipEmpty;
result=m_temperature.section(':', 0, 0);
empid=m_temperature.section(':', 1, 1);
empid_no=m_temperature.section(':', 2, 2);
companyname==m_temperature.section(':', 4, 4);