Skip to content

Commit

Permalink
working example of download
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupesh Yadav committed Sep 11, 2014
1 parent 926c47c commit aedf342
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 82 deletions.
6 changes: 3 additions & 3 deletions Widget/Widget.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.1, 2014-09-11T14:33:58. -->
<!-- Written by QtCreator 3.1.1, 2014-09-11T16:02:25. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down Expand Up @@ -231,8 +231,8 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Widget</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/RADIXLOCAL/rupesh.yadav/Widget/Widget.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Widget2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/RADIXLOCAL/rupesh.yadav/QtProjects/Widget/Widget.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Widget.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
Expand Down
12 changes: 8 additions & 4 deletions Widget/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->addressBar->setText("http:https://textfiles.com/100/914bbs.txt");
}

MainWindow::~MainWindow()
Expand All @@ -19,13 +20,16 @@ void MainWindow::on_pushButton_clicked()
QUrl url(HttpAddress);
request.setUrl(url);
reply = manager.get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(readyRead()), SLOT(slotReadyRead()));
}
void MainWindow::slotReadyRead(){
file = new QFile("DownloadedData.txt");
file->open(0,QIODevice::ReadWrite);
file->write(reply->readAll());
QByteArray bArray = reply->readAll();
QString tempString = bArray.data();
ui->textEdit->append(tempString);
ui->textEdit->append(reply->url().fileName());
file = new QFile();
file->setFileName(reply->url().fileName());
file->open(QIODevice::WriteOnly);
file->write(reply->readAll());
file->close();
}
73 changes: 0 additions & 73 deletions first/914bbs.txt

This file was deleted.

4 changes: 3 additions & 1 deletion first/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@ void DownloadManager::downloadFinished()

void DownloadManager::downloadReadyRead()
{
output.write(currentDownload->readAll());
QByteArray tempByteArray = currentDownload->readAll();
QString tempString = tempByteArray.data();
output.write(tempByteArray);
}
Binary file modified first/downloadmanager.o
Binary file not shown.
Binary file modified first/first
Binary file not shown.
2 changes: 1 addition & 1 deletion first/first.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.1, 2014-09-11T14:30:52. -->
<!-- Written by QtCreator 3.1.1, 2014-09-11T15:52:25. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down

0 comments on commit aedf342

Please sign in to comment.