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. QNetworkAccessManager crashes outside Qt Creator

QNetworkAccessManager crashes outside Qt Creator

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.0k 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.
  • T Offline
    T Offline
    Thegreger
    wrote on last edited by
    #1

    I migth be doing something fundamentally wrong here, but my approach is in line with the examples that I've managed to find online. It seems that calling the QNetworkAccessManager constructor crashes my program with an undefined "runtime error" in Windows 8.1. I've successfully used it inside Qt Creator, but as soon as I try to use it as a stand-alone program it crashes.

    Even this very minimal code replicates the problem (simply a form with a button). The program crashes immidiately when I click the pushButton, _only _ if I run the program outside Qt Creator.

    mainwindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include "QtNetwork"
    #include "QtNetwork/QNetworkAccessManager"
    #include "QtNetwork/QNetworkReply"

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private slots:
    void on_pushButton_clicked();

    private:
    Ui::MainWindow *ui;
    QNetworkAccessManager *grabber;
    };

    #endif // MAINWINDOW_H@

    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pushButton_clicked()
    {
    grabber = new QNetworkAccessManager(this);
    }@

    Am I doing something wrong here? It doesn't seem like there's a lot of room for mistakes...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The codes looks good.

      Did you deploy the bearer plugin with your application ?

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

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Sure, "here":http://qt-project.org/wiki/Deploy_an_Application_on_Windows is a fine wiki entry about Windows application deployment. The bearer plugins are in the bearer sub-directory

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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Thegreger
          wrote on last edited by
          #4

          Thanks, that did the trick!
          I had already copied the plugins, though I had copied the "plugin" directory rather than the individual directories into my program directory.

          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