Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

QNetworkReply keine Daten

Empfohlene Antworten

Veröffentlicht

Hallo,

ich versuche mich gerade etwas an c++ und QT4.

Ich bekomme leider keine Daten zurück wenn ich einen Request starte.


QNetworkRequest request;

    request.setUrl(QUrl("www.google.de")); //this->settings->value("url").toString()


    QNetworkReply *reply = this->network->get(request);


    QString replystring(reply->readAll());

    qDebug() << replystring;

    qDebug() << reply->errorString();

    qDebug() << reply->error();

    qDebug() << reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();

Ausgabe:

"" 

"Unknown error" 

0 

0 

Wäre nett, wenn du für zukünftige Leser die Lösung noch drunterpacken würdest ;)

Sonst sucht jemand nach dem Problem, stößt auf diesen Threads und hasst dich dafür, dass du die Lösung wießt, sie aber nicht mitteilst ;)

  • Autor

Hast recht:


 this->network = new QNetworkAccessManager(this);

    QObject::connect(this->network, SIGNAL(finished(QNetworkReply *)),

                                    SLOT(slotRequestFinished(QNetworkReply *)))




void LoginDialog::slotRequestFinished(QNetworkReply *reply)

{

    QString replystring(reply->readAll());

    QMessageBox msgBox;


    qDebug() << reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();


    if(reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200)

    {

        //login Error

        msgBox.critical(0,"Error",replystring +" HTTP Code:"+ reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt());

    }

    else

    {


    }


}


Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.