diff --git a/examples/webenginewidgets/webui/main.cpp b/examples/webenginewidgets/webui/main.cpp
index 54e0c145cff17d076b8a92a435858dd43cf5eb92..3e9f61fe4ce1a6125b93c2db99a3c9f5e56770e7 100644
--- a/examples/webenginewidgets/webui/main.cpp
+++ b/examples/webenginewidgets/webui/main.cpp
@@ -58,6 +58,7 @@
 int main(int argc, char *argv[])
 {
     QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
     WebUiHandler::registerUrlScheme();
 
     QApplication app(argc, argv);
@@ -65,10 +66,10 @@ int main(int argc, char *argv[])
     QWebEngineProfile profile;
 
     WebUiHandler handler;
-    profile.installUrlSchemeHandler(QByteArrayLiteral("webui"), &handler);
+    profile.installUrlSchemeHandler(WebUiHandler::schemeName, &handler);
 
     QWebEnginePage page(&profile);
-    page.load(QStringLiteral("webui:about"));
+    page.load(WebUiHandler::aboutUrl);
 
     QWebEngineView view;
     view.setPage(&page);
diff --git a/examples/webenginewidgets/webui/webuihandler.cpp b/examples/webenginewidgets/webui/webuihandler.cpp
index 42446b88e6b6384df9ab8436c2f7df4854ca296f..246af9d07e4faa26ab4946f0d54567bb466df40d 100644
--- a/examples/webenginewidgets/webui/webuihandler.cpp
+++ b/examples/webenginewidgets/webui/webuihandler.cpp
@@ -55,6 +55,11 @@
 #include <QWebEngineUrlRequestJob>
 #include <QWebEngineUrlScheme>
 
+#define SCHEMENAME "webui"
+
+const QByteArray WebUiHandler::schemeName = QByteArrayLiteral(SCHEMENAME);
+const QUrl WebUiHandler::aboutUrl = QUrl(QStringLiteral(SCHEMENAME ":about"));
+
 WebUiHandler::WebUiHandler(QObject *parent)
     : QWebEngineUrlSchemeHandler(parent)
 {
@@ -62,8 +67,7 @@ WebUiHandler::WebUiHandler(QObject *parent)
 
 void WebUiHandler::requestStarted(QWebEngineUrlRequestJob *job)
 {
-    static const QUrl webuiAboutUrl(QStringLiteral("webui:about"));
-    static const QUrl webUiOrigin(QStringLiteral("webui:"));
+    static const QUrl webUiOrigin(QStringLiteral(SCHEMENAME ":"));
     static const QByteArray GET(QByteArrayLiteral("GET"));
     static const QByteArray POST(QByteArrayLiteral("POST"));
 
@@ -71,11 +75,11 @@ void WebUiHandler::requestStarted(QWebEngineUrlRequestJob *job)
     QUrl url = job->requestUrl();
     QUrl initiator = job->initiator();
 
-    if (method == GET && url == webuiAboutUrl) {
+    if (method == GET && url == aboutUrl) {
         QFile *file = new QFile(QStringLiteral(":/about.html"), job);
         file->open(QIODevice::ReadOnly);
         job->reply(QByteArrayLiteral("text/html"), file);
-    } else if (method == POST && url == webuiAboutUrl && initiator == webUiOrigin) {
+    } else if (method == POST && url == aboutUrl && initiator == webUiOrigin) {
         job->fail(QWebEngineUrlRequestJob::RequestAborted);
         QApplication::exit();
     } else {
@@ -86,7 +90,7 @@ void WebUiHandler::requestStarted(QWebEngineUrlRequestJob *job)
 // static
 void WebUiHandler::registerUrlScheme()
 {
-    QWebEngineUrlScheme webUiScheme(QByteArrayLiteral("webui"));
+    QWebEngineUrlScheme webUiScheme(schemeName);
     webUiScheme.setFlags(QWebEngineUrlScheme::Secure |
                          QWebEngineUrlScheme::Local |
                          QWebEngineUrlScheme::LocalAccessAllowed);
diff --git a/examples/webenginewidgets/webui/webuihandler.h b/examples/webenginewidgets/webui/webuihandler.h
index f9d7b91df6a17ea8974c40092b6efef2ccd8c62e..f2ac0dcefb15d371e9aaa05fce3b8d4b0670aeaa 100644
--- a/examples/webenginewidgets/webui/webuihandler.h
+++ b/examples/webenginewidgets/webui/webuihandler.h
@@ -62,6 +62,9 @@ public:
     void requestStarted(QWebEngineUrlRequestJob *job) override;
 
     static void registerUrlScheme();
+
+    const static QByteArray schemeName;
+    const static QUrl aboutUrl;
 };
 
 #endif // !WEBUIHANDLER_H