Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MainWindow::Pobierz()
- { manager = new QNetworkAccessManager(this);
- connect(manager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(replyFinished(QNetworkReply*)));
- //manager->get(QNetworkRequest(QUrl("http://www.nbp.pl/kursy/xml/LastA.xml")));
- manager->get(QNetworkRequest(QUrl("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml")));
- }
- void MainWindow::replyFinished (QNetworkReply *reply)
- {
- if (reply->error() == QNetworkReply::NoError)
- {
- QString filename = "walutkiy.xml";
- QFile file(filename);
- // Trying to open in WriteOnly and Text mode
- if(!file.open(QFile::WriteOnly |
- QFile::Text))
- {
- qDebug() << " Could not open file for writing";
- return;
- }
- // To write text, we use operator<<(),
- // which is overloaded to take
- // a QTextStream on the left
- // and data types (including QString) on the right
- QTextStream out(&file);
- out<<reply->readAll();
- file.flush();
- file.close();
- // file.open(QIODevice::ReadOnly);
- // doc.setContent(&file);
- // file.close();
- }
- else
- {
- ui->komunikat_2->setText("nie dziala error przy pobieraniu");
- }
- reply->deleteLater();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement