problem with QNetworkAccessManager
-
should i make a call to a server locally using QNetworkAccessManager, i am using qt6 and cmake. The build works correctly, but when they run the program ends instantly with the error "Process finished with exit code -1073741515 (0xC0000135)".
This is my code:code_text ```void login::checkLogin() { QString username = ui->username_et->text(); QString password = ui->username_et->text(); QUrl url("http://localhost/ServerProgettoPDS/calendarserver.php/"); url.setUserName(username); url.setPassword(password); QNetworkAccessManager *manager; = new QNetworkAccessManager(this); manager->get(QNetworkRequest(url)); QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*))); } ________________________________________ bool login::finishedSlot(QNetworkReply* reply){ reply->readAll(); std::cout << reply->readAll().toStdString(); return true; }``` code_text
-
Hi,
@millo98 said in problem with QNetworkAccessManager:
*manager; = new QNetworkAccessManager(this);
Here lies your issue.
-
and you create a new QNetworkAccessManager every time checkLogin() is called. Only create it once in the ctor.
-
@millo98 said in problem with QNetworkAccessManager:
@SGaist ; is not present in this line,
Please paste actual code (that compiles), rather than something which you say is not actually there, if you expect people to spend their time and help....
but don't work anyway
reply->readAll(); std::cout << reply->readAll().toStdString();
This does not print what is there and read, if that is what you mean by "but don't work anyway". It will just print an empty string, always.
-
this is my code actual code:
login.h
#ifndef LOGIN_H #define LOGIN_H #include <QDialog> #include "event.h" #include "window.h" #include <QNetworkAccessManager> namespace Ui { class login; } class login : public QDialog{ Q_OBJECT public: explicit login(QWidget *parent = nullptr); ~login(); private: Ui::login *ui; Window *window; void checkLogin(); void finishedSlot(QNetworkReply* reply); QNetworkAccessManager *manager; }; #endif //LOGIN_H
and in login.cpp i have the costructor
login::login(QWidget *parent) : QDialog(parent), ui(new Ui::login) { ui->setupUi(this); //connect pulsante login connect(ui->loginbtn, &QPushButton::clicked, this, [=](){ checkLogin(); }); manager = new QNetworkAccessManager(this); }
the program build but don't run with 'Process finished with exit code -1073741515 (0xC0000135)'
-
@millo98 said in problem with QNetworkAccessManager:
the program build but don't run with 'Process finished with exit code -1073741515 (0xC0000135)'
Use a debugger to see where it crashes...
/edit: 0xC0000135 looks like a missing dll, can you start debugging at all?