int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QTextCodec::setCodecForTr( QTextCodec::codecForName("gb2312")); QStringList args = app.arguments(); if (args.count() !=2){ qDebug()<<QObject::tr("М├ие: wget url")<<endl <<QObject::tr("└§:")<<endl <<QObject::tr(" wget http://www.gnu.org/software/wget/manual/wget.txt"); return -1; } HttpGet httpClient; if (!httpClient.downloadFile(QUrl(args[1]))) return -1; QObject::connect(&httpClient,SIGNAL(done()),&app,SLOT(quit())); return app.exec(); }
void MainWindow::saveBtn_Clicked() { QDir dir(savePath); if (!dir.exists()) { dir.mkdir(savePath); } ui.saveBtn->setEnabled(false); int con = list.count(); for (int i = 0; i < con;i++) { QUrl url(list[i]); QFileInfo fileInfo(url.path()); QString fileName = fileInfo.fileName(); QString str = savePath +"\\"+ fileName; HttpGet* getter = new HttpGet(this); getter->downloadFile(url,str); } ui.saveBtn->setEnabled(true); }