QUrl url = QUrl::fromUserInput(strUrl); QFileInfo fileInfo(url.path()); QString fileName=fileInfo.fileName(); if (QFile::exists(fileName)) { QMessageBox::information(this, tr("HTTP"), tr("There already exists a file called %1 in " "the current directory.") .arg(fileName)); } file = new QFile(fileName); if (!file->open(QIODevice::WriteOnly)) { QMessageBox::information(this, tr("HTTP"), tr("Unable to save the file %1: %2.") .arg(fileName).arg(file->errorString())); delete file; file = 0; } file.setFileName(fileName); file.open(QIODevice::WriteOnly); QHttp http; QEventLoop loop; QFile file; QObject::connect(&http, SIGNAL(done(bool)), &loop, SLOT(quit())); file.setFileName(filename); file.open(QIODevice::WriteOnly); http.setHost(url.host(), url.port(80)); http.get(url.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority), &file); loop.exec();
connect
get
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)