0

it is my code for conversion from QScriptValue to QVariantList .But i am getting error on the last line. please correct me if i am doing something wrong.

    void ApplicationUI::onResult(QNetworkReply* reply)
    {

        if (reply->error() != QNetworkReply::NoError){
            return;  // ...only in a blog post
        }
        QString data = (QString) reply->readAll();
        QScriptEngine engine;
        QScriptValue result = engine.evaluate("(" + data + ")");
        QScriptValue entries = result.property("result");


        QVariantList *mainListd=entries.toVariant().toList();

}

I want to insert this mainListd in GroupDataModel.

Usama Sadiq
  • 587
  • 1
  • 4
  • 21
  • I guess your data is formated in JSON? If so, ``QScriptValue`` is maybe not the right way to do it, as you can use ``JsonDataAccess`` to parse JSON data. – Marc Plano-Lesay Aug 01 '13 at 12:46
  • Yes you are right JsonDataAccess is one of the best way to parse . but if i do in the required way then i solve my problem by removing pointer. – Usama Sadiq Aug 02 '13 at 05:24

1 Answers1

0

QVariant::toList() returns a QList<QVariant>. You're trying to store it in a QVariantList*, which is in fact a QList<QVariant>*. You shouldn't be using a pointer here.

Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75