diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 69ccd7a316ae512f7994ea1ee51f7a0589ce2a15..e06f249b40cb5e280475ef4c72bd4b248978d7ab 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -494,6 +494,7 @@ int main(int argc, char *argv[])
 
     foreach (const QString &path, files) {
         //QUrl::fromUserInput doesn't treat no scheme as relative file paths
+#ifndef QT_NO_REGULAREXPRESSION
         QRegularExpression urlRe("[[:word:]]+://.*");
         if (urlRe.match(path).hasMatch()) { //Treat as a URL
             QUrl url = QUrl::fromUserInput(path);
@@ -503,7 +504,9 @@ int main(int argc, char *argv[])
                         ? QDir::toNativeSeparators(url.toLocalFile())
                         : url.toString()));
             e.load(url);
-        } else { //Local file path
+        } else
+#endif
+        { //Local file path
             if (verboseMode)
                 printf("qml: loading %s\n", qPrintable(QDir::toNativeSeparators(path)));