Get a QString from a QJsonobject



  • Does enybodu know why this is not working ?

    QByteArray backendId("here comes the backendid");
    EnginioClient *client = new EnginioClient;
    client->setBackendId(backendId);

    Login* l = new Login("User","name");
    
    QJsonObject aanmelden;
    aanmelden["objectType"] = QString::fromUtf8("objects.Login");
    aanmelden["id"] = QString::fromUtf8("53d95145698b3c37cd05f84c");
    const EnginioReply* reply = client->query(aanmelden);
    
    QString naam = aanmelden["Username"].toString();
    
    l->setUsername(naam);
    
    ui->label->setText(l->getUsername());
    

    I would like to create a login.



  • What exactly is not working?



  • the label is empty. So I think that the QString naam has not the wright data from the QJsonObject.



  • anmelden["Username"] is not assign in your code so if you call toString() on it, the result will be empty. The query() function is not modifying arguments.

    The important part is here:
    EnginioReply* reply = client->query(aanmelden)

    the reply is an object that will have the data (EnginioReply::data()) you are asking for. The data will be valid after finished() signal is emitted. Please look into examples, they show how to handle it.

    Btw. I guess that you are writing a login screen or something similar, Enginio has already a user management which you could use (http://qt-project.org/doc/qt-5/enginioclientconnection.html#identity-prop https://developer.qtcloudservices.com/eds/key-concepts/users-usergroups)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.