diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-25 10:11:33 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-25 10:11:33 +0100 |
| commit | 6318845388852c3eccb15ddce619389a3d49317d (patch) | |
| tree | babc6ad3e79675cbdd949e257153a28892c0cde7 /webengine.hpp | |
| parent | 41652d5f074943cd5fecb4396edec0a8c22f7c7c (diff) | |
set background color on load to black
Diffstat (limited to 'webengine.hpp')
| -rw-r--r-- | webengine.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/webengine.hpp b/webengine.hpp index 08cdbe5..dc73d97 100644 --- a/webengine.hpp +++ b/webengine.hpp @@ -17,6 +17,28 @@ #error "(The moc has changed too much.)" #endif +class WebEnginePage: public QWebEnginePage { +Q_OBJECT +public: + WebEnginePage(QWebEngineProfile *profile) : QWebEnginePage(profile) {}; + virtual ~WebEnginePage() = default; + +protected: + QWebEnginePage *createWindow(WebWindowType){ + WebEnginePage *page = new WebEnginePage(this->profile()); + connect(page, &QWebEnginePage::urlChanged, this, &WebEnginePage::onUrlChanged); + return page; + } + +private: + void onUrlChanged(const QUrl & url){ + if(WebEnginePage *page = qobject_cast<WebEnginePage *>(sender())){ + setUrl(url); + page->deleteLater(); + } + } +}; + QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED |