QWebView - checking several links
-
Hi, I wrote a program that checks if the link is correct. All shows correctly only when I throw a few links there is a problem and checks only one link (the last). Below throw program code:
mainwindow.h
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QUrl>
#include <Qstring>
#include <QWebFrame>
#include <QWebView>
#include <QWebElement>
#include <QWebElementCollection>
#include <QDebug>
#include <string>
#include <QTableWidgetItem>
#include <QHeaderView>
#include <sstream>using namespace std;
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
QWebView *qwv = new QWebView();
~MainWindow();private slots:
void lnk_turbobit();
void lnk_rapidgator();
void lnk_catshare();
void on_pushButton_clicked();
void finished(bool);private:
Ui::MainWindow *ui;
QUrl lnk;
unsigned int licznik = -1;
unsigned int width = 0;
unsigned int width2 = 0;
};#endif // MAINWINDOW_H
@mainwindow.cpp
@#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "load.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);}
MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_pushButton_clicked()
{
QString rep_lnk = ui->textEdit->toPlainText();
string buffor;
istringstream is(rep_lnk.toStdString());unsigned int j = 0; while(getline(is, buffor)) { QString rep_lnk2 = buffor.c_str(); rep_lnk2.replace(" ", ""); rep_lnk2.replace("\n", ""); qDebug() << rep_lnk2; lnk = rep_lnk2; qwv->setUrl(lnk); ui->label->setText("Sprawdzanie linków"); connect(qwv, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool))); } licznik ++;
}
void MainWindow::finished(bool)
{ui->label->setText("Zakończono sprawdzanie linków"); QString file; unsigned int n; file = lnk.toString(); n = file.toStdString().find("turbobit"); if(n != string::npos) lnk_turbobit(); n = file.toStdString().find("rapidgator"); if(n != string::npos) lnk_rapidgator(); n = file.toStdString().find("catshare"); if(n != string::npos) lnk_catshare(); //lnk_turbobit(); //lnk_rapidgator(); //lnk_catshare();
}
...
@ -
Hi,
@
while(getline(is, buffor))
{QString rep_lnk2 = buffor.c_str(); rep_lnk2.replace(" ", ""); rep_lnk2.replace("\n", ""); qDebug() << rep_lnk2; lnk = rep_lnk2; qwv->setUrl(lnk); ui->label->setText("Sprawdzanie linków"); connect(qwv, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool))); }
@
In this loop you don't wait for the loading to end and replace the current url on each iteration.
-
That's how it is. Only now just do not know how to do to be waiting at the end of each link.
-
There are several possibilities one being to use signals and slots and a singleShot QTimer when the loading has finished