C++ (Qt)class MainWindow : public QMainWindow { Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow(); protected: void changeEvent(QEvent *e); private: Ui::MainWindow *ui; QNetworkReply *reply; QNetworkAccessManager *manager; }; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QUrl address("http://www.ya.ru/"); manager = new QNetworkAccessManager(this); reply = manager->get(QNetworkRequest(address)); connect(reply, SIGNAL(finished()), this, SLOT(close())); QTimer *timer = new QTimer(this); timer->start(100); connect(timer, SIGNAL(timeout()), this, SLOT(close())); }
delete manager;
C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QUrl address("http://www.ya.ru/"); manager = new QNetworkAccessManager(this); reply = manager->get(QNetworkRequest(address)); connect(reply, SIGNAL(finished()), qApp, SLOT(quit())); QTimer *timer = new QTimer(this); timer->start(100); connect(timer, SIGNAL(timeout()), qApp, SLOT(quit())); }
C++ (Qt) QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();
C++ (Qt)MainWindow::~MainWindow(){ delete manager; delete ui;}