diff --git a/gb.qt5/src/webview/c_webview.cpp b/gb.qt5/src/webview/c_webview.cpp index a0ce8d7d3..3772767e7 100644 --- a/gb.qt5/src/webview/c_webview.cpp +++ b/gb.qt5/src/webview/c_webview.cpp @@ -283,12 +283,13 @@ BEGIN_METHOD(WebView_new, GB_OBJECT parent) QObject::connect(wid, SIGNAL(iconChanged(const QIcon &)), &WebViewSignalManager::manager, SLOT(iconChanged())); QObject::connect(wid, SIGNAL(titleChanged(const QString &)), &WebViewSignalManager::manager, SLOT(titleChanged())); QObject::connect(wid, SIGNAL(urlChanged(const QUrl &)), &WebViewSignalManager::manager, SLOT(urlChanged())); - QObject::connect(wid->page(), SIGNAL(linkHovered(const QString &)), &WebViewSignalManager::manager, SLOT(linkHovered(const QString &))); QObject::connect(wid, SIGNAL(loadStarted()), &WebViewSignalManager::manager, SLOT(loadStarted())); QObject::connect(wid, SIGNAL(loadProgress(int)), &WebViewSignalManager::manager, SLOT(loadProgress(int))); QObject::connect(wid, SIGNAL(loadFinished(bool)), &WebViewSignalManager::manager, SLOT(loadFinished(bool))); - //QObject::connect(wid, SIGNAL(linkClicked(const QUrl &)), &CWebView::manager, SLOT(linkClicked(const QUrl &))); + wid->clearPage(false); + + //QObject::connect(wid, SIGNAL(linkClicked(const QUrl &)), &CWebView::manager, SLOT(linkClicked(const QUrl &))); #if 0 QObject::connect(wid, SIGNAL(selectionChanged()), &CWebView::manager, SLOT(selectionChanged())); QObject::connect(wid, SIGNAL(statusBarMessage(const QString &)), &CWebView::manager, SLOT(statusBarMessage(const QString &))); @@ -432,9 +433,7 @@ END_PROPERTY BEGIN_METHOD_VOID(WebView_Clear) - //delete WIDGET->page(); - WIDGET->setPage(new MyWebPage(WIDGET)); - QObject::connect(WIDGET->page(), SIGNAL(linkHovered(const QString &)), &WebViewSignalManager::manager, SLOT(linkHovered(const QString &))); + WIDGET->clearPage(true); END_METHOD @@ -945,6 +944,19 @@ MyWebEngineView::MyWebEngineView(QWidget *parent) : QWebEngineView(parent) setPage(new MyWebPage(this)); } +void MyWebEngineView::clearPage(bool destroy) +{ + QWebEnginePage *p; + if (destroy) + p = page(); + + setPage(new MyWebPage(this)); + QObject::connect(page(), SIGNAL(linkHovered(const QString &)), &WebViewSignalManager::manager, SLOT(linkHovered(const QString &))); + + if (destroy) + delete p; +} + QWebEngineView *MyWebEngineView::createWindow(QWebEnginePage::WebWindowType type) { void *_object = QT.GetObject(this); diff --git a/gb.qt5/src/webview/c_webview.h b/gb.qt5/src/webview/c_webview.h index e9f935513..b434e6604 100644 --- a/gb.qt5/src/webview/c_webview.h +++ b/gb.qt5/src/webview/c_webview.h @@ -79,6 +79,7 @@ class MyWebEngineView : public QWebEngineView public: MyWebEngineView(QWidget *parent); + void clearPage(bool del); protected: