Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as C++ by yoba ( 14 years ago )
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
 
#include <QtCore>
 
#include <QtNetwork/QtNetwork>
#include <QDebug>
#include <QString>
#include <QIcon>
 
 
#include <QtGui>
 
class MainWindow : public QMainWindow
{
    Q_OBJECT
 
public:
    MainWindow(QWidget *parent = 0, QString link);   
 
    QString link;
    
    QIcon* icon;
    QByteArray* byteArr; 
   
 
    ~MainWindow();
 
private:
    QNetworkAccessManager *pNetManager;
 
public slots:
    void slotReadyRead();
    void slotError(QNetworkReply::NetworkError);
    void slotFinished();
};
 
#endif // MAINWINDOW_H
 
 
 
 
#include "mainwindow.h"
 
MainWindow::MainWindow(QWidget *parent, QString link)
    : QMainWindow(parent)
{
    pNetManager = new QNetworkAccessManager(this);
 
    QNetworkRequest request;
    request.setUrl(QUrl(link));
  //  request.setRawHeader("Accept-Encoding", "gzip,deflate");
    QNetworkReply *reply = pNetManager->get(request);
    connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
                this, SLOT(slotError(QNetworkReply::NetworkError)));
    connect(reply, SIGNAL(finished()), this, SLOT(slotFinished()));     
 
}
 
void MainWindow::slotReadyRead()
{
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
   
}
void MainWindow::slotFinished()
{   
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
    byteArr = reply->readAll();
    icon = byteArr;
    reply->deleteLater();
}
void MainWindow::slotError(QNetworkReply::NetworkError error)
{
 
}
 
MainWindow::~MainWindow()
{
 
}

 

Revise this Paste

Parent: 22552
Your Name: Code Language: