Qt World Summit: Register Today!

QNetworkAccessManager crashes outside Qt Creator

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

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

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

    namespace Ui {
    class MainWindow;

    class MainWindow : public QMainWindow

    explicit MainWindow(QWidget *parent = 0);

    private slots:
    void on_pushButton_clicked();

    Ui::MainWindow *ui;
    QNetworkAccessManager *grabber;

    #endif // MAINWINDOW_H@

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

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::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...

  • Lifetime Qt Champion


    The codes looks good.

    Did you deploy the bearer plugin with your application ?

  • Lifetime Qt Champion

    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

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

Log in to reply