Hi,
I want to pass the PortalSearchItems list to be passed from qml to Cpp. Eventhough, I can get the result, app got just killed, when this code executes. I assume performance issue.
Code Snippet: main.qml
--------------------------------------
var varidPortalSearchItemsCount = idPortalSearchItems.totalResults;
var vartextJson = "";
for (var ii = 0; ii <= varidPortalSearchItemsCount -1 ;ii++)
{
vartextJson += '{"title":"'+ idPortalSearchItems.results[ii].title +'"
,"owner":"'+ idPortalSearchItems.results[ii].owner +'"
,"url":"'+ idPortalSearchItems.results[ii].url +'"
,"itemId":"'+ idPortalSearchItems.results[ii].itemId +'"
}' + ',';
}
vartextJson = vartextJson.substring(0, vartextJson.length-1) + ']';
vartextJson = '[' + vartextJson;
var varJsonString =JSON.parse(vartextJson);
objHomeController.eveWriteXML(varJsonString);
var varidPortalSearchItemsCount = idPortalSearchItems.totalResults;
var vartextJson = "";
for (var ii = 0; ii <= varidPortalSearchItemsCount -1 ;ii++)
{
vartextJson += '{"title":"'+ idPortalSearchItems.results[ii].title +'"
,"owner":"'+ idPortalSearchItems.results[ii].owner +'"
,"url":"'+ idPortalSearchItems.results[ii].url +'"
,"itemId":"'+ idPortalSearchItems.results[ii].itemId +'"
}' + ',';
}
vartextJson = vartextJson.substring(0, vartextJson.length-1) + ']';
vartextJson = '[' + vartextJson;
var varJsonString =JSON.parse(vartextJson);
objHomeController.eveWriteXML(varJsonString);
To copy to clipboard, switch view to plain text mode
HomeController.h
--------------------------
Q_INVOKABLE bool eveWriteXML(const QJsonObject &pqvarPortalItemResult);
Q_INVOKABLE bool eveWriteXML(const QJsonObject &pqvarPortalItemResult);
To copy to clipboard, switch view to plain text mode
HomeController.cpp
--------------------------
bool HomeController::eveWriteXML(const QJsonObject &pqvarPortalItemResult)
{
QVariantMap jsonQVariantMap = pqvarPortalItemResult.toVariantMap();
for(QVariantMap::const_iterator iter = jsonQVariantMap.begin(); iter != jsonQVariantMap.end(); ++iter) {
QString strTitleValue
= objQVariant1.
toMap().
values("title").
value(0).
toString();
QString strUrlValue
= objQVariant1.
toMap().
values("url").
value(0).
toString();
QString strOwnerValue
= objQVariant1.
toMap().
values("owner").
value(0).
toString();
QString strItemIdValue
= objQVariant1.
toMap().
values("itemId").
value(0).
toString();
}
bool HomeController::eveWriteXML(const QJsonObject &pqvarPortalItemResult)
{
QVariantMap jsonQVariantMap = pqvarPortalItemResult.toVariantMap();
for(QVariantMap::const_iterator iter = jsonQVariantMap.begin(); iter != jsonQVariantMap.end(); ++iter) {
QVariant objQVariant = iter.key();
QVariant objQVariant1 = iter.value();
QString strTitleValue = objQVariant1.toMap().values("title").value(0).toString();
QString strUrlValue = objQVariant1.toMap().values("url").value(0).toString();
QString strOwnerValue = objQVariant1.toMap().values("owner").value(0).toString();
QString strItemIdValue = objQVariant1.toMap().values("itemId").value(0).toString();
}
To copy to clipboard, switch view to plain text mode
Thanks In advance.
Bookmarks