Hi all,
I have created the simplest Qt (5.0.0) application using VS Add-in.
Added the simplest network request:
test.h
#ifndef TEST_H
#define TEST_H
#include <QtWidgets/QMainWindow>
#include <QtNetwork>
#include "ui_test.h"
{
Q_OBJECT
public:
~Test();
public slots:
void Button_clicked();
void Request_finished(QNetworkReply *reply);
private:
Ui::TestClass ui;
};
#endif // TEST_H
#ifndef TEST_H
#define TEST_H
#include <QtWidgets/QMainWindow>
#include <QtNetwork>
#include "ui_test.h"
class Test : public QMainWindow
{
Q_OBJECT
public:
Test(QWidget *parent = 0);
~Test();
public slots:
void Button_clicked();
void Request_finished(QNetworkReply *reply);
private:
Ui::TestClass ui;
};
#endif // TEST_H
To copy to clipboard, switch view to plain text mode
test.cpp
#include "test.h"
#include <QtWidgets>
{
ui.setupUi(this);
QObject::connect(ui.
pushButton,
SIGNAL(clicked
()),
this,
SLOT(Button_clicked
()));
}
Test::~Test()
{
}
void Test::Button_clicked()
{
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
QObject::connect(manager,
SIGNAL(finished
(QNetworkReply
*)),
this,
SLOT(Request_finished
(QNetworkReply
*)));
QNetworkRequest request
(QUrl("http://www.google.com"));
QNetworkReply *reply = manager->get(request);
}
void Test::Request_finished(QNetworkReply *reply)
{
reply->deleteLater();
}
#include "test.h"
#include <QtWidgets>
Test::Test(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(Button_clicked()));
}
Test::~Test()
{
}
void Test::Button_clicked()
{
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));
QNetworkRequest request(QUrl("http://www.google.com"));
QNetworkReply *reply = manager->get(request);
}
void Test::Request_finished(QNetworkReply *reply)
{
reply->deleteLater();
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include "test.h"
#include "qmyapp.h"
int main(int argc, char *argv[])
{
Test w;
w.show();
return a.exec();
}
#include "test.h"
#include "qmyapp.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Test w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
test.ui contains a single QPushButton pushButton.
Now if I start application and press button, then after main window destroyed I receive the following line in VS Output window:
First-chance exception at 0x74e5b9bc in Test.exe: 0x0000000D: The data is invalid.
What's wrong?
Thank you.
Bookmarks