#include <QWebView>
#include <QObject>
class MyWebview : public QObject {
Q_OBJECT
private:
QWebView *v1, *v2, *v3, *v4;
public:
MyWebview() {
v1 = new QWebView(0);
v2 = new QWebView(0);
v3 = new QWebView(0);
v4 = new QWebView(0);
v1->load(QUrl("http://google.com"));
v2->load(QUrl("http://facebook.com"));
v3->load(QUrl("http://bing.com"));
v4->load(QUrl("http://twitter.com"));
connect(v1, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
connect(v2, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
connect(v3, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
connect(v4, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
}
public slots:
void MyWebview::finished(bool ok) { // [ SLOT ]
switch( /**/ ) {
case /*if it is v1*/:
disconnect(v1, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
break;
case /*if it is v2*/:
disconnect(v2, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
break;
case /*if it is v3*/:
disconnect(v3, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
break;
case /*if it is v3*/:
disconnect(v4, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
break;
}
// do something..
}
}
如何解决这种情况?感谢。