Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem with QNetworkAccessManager
Forum Updated to NodeBB v4.3 + New Features

problem with QNetworkAccessManager

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 616 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    millo98
    wrote on last edited by millo98
    #1

    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
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      @millo98 said in problem with QNetworkAccessManager:

      *manager; = new QNetworkAccessManager(this);

      Here lies your issue.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        and you create a new QNetworkAccessManager every time checkLogin() is called. Only create it once in the ctor.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          @millo98 said in problem with QNetworkAccessManager:

          *manager; = new QNetworkAccessManager(this);

          Here lies your issue.

          M Offline
          M Offline
          millo98
          wrote on last edited by
          #4

          @SGaist ; is not present in this line, but don't work anyway

          JonBJ 1 Reply Last reply
          0
          • M millo98

            @SGaist ; is not present in this line, but don't work anyway

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @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.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              millo98
              wrote on last edited by
              #6

              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)'

              Christian EhrlicherC 1 Reply Last reply
              0
              • M millo98

                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)'

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #7

                @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?

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved