I'm trying to make a program that downloads an image and saves it to the disk. Using C++ I've followed a reference for the downloading of a file, but how would I save it to disk? My code as I have it now gives me allot of unresolved external symbols. When I comment out lines 40 - 44 everything compiles successfully..
My Code: (I ended up putting everything under the button clicked function)
#include "minecraftskindownloader.h"
#include "ui_minecraftskindownloader.h"
#include <QWidget>
#include <QObject>
#include <QtNetwork/QNetworkAccessManager>
#include <QFileDialog>
#include <C:\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtNetwork\QNetworkRequest>
#include <QDebug>
#include <QUrl>
#include <QFile>
MinecraftSkinDownloader
::MinecraftSkinDownloader(QWidget *parent
) : ui(new Ui::MinecraftSkinDownloader)
{
ui->setupUi(this);
this->setWindowTitle("Minecraft Skin Downloader");
setFixedSize(400, 200);
}
MinecraftSkinDownloader::~MinecraftSkinDownloader()
{
delete ui;
}
void MinecraftSkinDownloader::on_actionClose_triggered()
{
qApp->quit();
}
//http://s3.amazonaws.com/MinecraftSkins/USERNAMEHERE.png
void MinecraftSkinDownloader::on_pushButton_clicked()
{
QString prefix
= "http://s3.amazonaws.com/MinecraftSkins/";
QString url
= prefix
+= ui
->lineEdit
->text
();
url += ".png";
ui->textEdit->setText(url); //Just testing the link part
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
SLOT(replyFinished(QNetworkReply*)));
manager
->get
(QNetworkRequest
(QUrl(url
)));
QString fileName
= QFileDialog::getSaveFileName(this, tr
("Save"),
"/Documents",tr
("Images (*.png)"));
}
#include "minecraftskindownloader.h"
#include "ui_minecraftskindownloader.h"
#include <QWidget>
#include <QObject>
#include <QtNetwork/QNetworkAccessManager>
#include <QFileDialog>
#include <C:\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtNetwork\QNetworkRequest>
#include <QDebug>
#include <QUrl>
#include <QFile>
MinecraftSkinDownloader::MinecraftSkinDownloader(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MinecraftSkinDownloader)
{
ui->setupUi(this);
this->setWindowTitle("Minecraft Skin Downloader");
setFixedSize(400, 200);
}
MinecraftSkinDownloader::~MinecraftSkinDownloader()
{
delete ui;
}
void MinecraftSkinDownloader::on_actionClose_triggered()
{
qApp->quit();
}
//http://s3.amazonaws.com/MinecraftSkins/USERNAMEHERE.png
void MinecraftSkinDownloader::on_pushButton_clicked()
{
QString prefix = "http://s3.amazonaws.com/MinecraftSkins/";
QString url = prefix += ui->lineEdit->text();
url += ".png";
ui->textEdit->setText(url); //Just testing the link part
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl(url)));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save"),"/Documents",tr("Images (*.png)"));
}
To copy to clipboard, switch view to plain text mode
Bookmarks