Hello!
I'm trying to run Qt WebView Example - Minibrowser on Qt 6.7.1(Microsoft Visual C++ Compiler 15.9.28307.1745 (amd64)) for Windows 11 (build 10.0.22631 home)
The code is taken from the official example http://doc.qt.io/qt-4.8/https://doc.qt.io/qt-6/qtwebview-minibrowser-example.html

Any attempts result in an error:
DXGI ERROR: CreateDXGIFactory cannot be called from DllMain. [MISCELLANEOUS ERROR #76:]

What can be done to solve the problem?

The code:
Qt Code:
  1. [/QTCLASS]// Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
  3.  
  4. #include <QtCore/QUrl>
  5. #include <QtCore/QCommandLineOption>
  6. #include <QtCore/QCommandLineParser>
  7. #include <QGuiApplication>
  8. #include <QStyleHints>
  9. #include <QScreen>
  10. #include <QQmlApplicationEngine>
  11. #include <QtQml/QQmlContext>
  12. #include <QtWebView/QtWebView>
  13.  
  14.  
  15. #include "main.moc"
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19. //! [0]
  20. QtWebView::initialize();
  21. QGuiApplication app(argc, argv);
  22.  
  23. //! [0]
  24. QGuiApplication::setApplicationDisplayName(QCoreApplication::translate("main",
  25. "QtWebView Example"));
  26. QCommandLineParser parser;
  27. QCoreApplication::setApplicationVersion(QT_VERSION_STR);
  28. parser.setApplicationDescription(QGuiApplication::applicationDisplayName());
  29. parser.addHelpOption();
  30. parser.addVersionOption();
  31. parser.addPositionalArgument("url", "The initial URL to open.");
  32. QStringList arguments = app.arguments();
  33. parser.process(arguments);
  34. const QString initialUrl = parser.positionalArguments().isEmpty() ?
  35. QStringLiteral("https://www.qt.io") : parser.positionalArguments().first();
  36.  
  37. QQmlApplicationEngine engine;
  38. QQmlContext *context = engine.rootContext();
  39. context->setContextProperty(QStringLiteral("utils"), new Utils(&engine));
  40. context->setContextProperty(QStringLiteral("initialUrl"),
  41. Utils::fromUserInput(initialUrl));
  42. QRect geometry = QGuiApplication::primaryScreen()->availableGeometry();
  43. if (!QGuiApplication::styleHints()->showIsFullScreen()) {
  44. const QSize size = geometry.size() * 4 / 5;
  45. const QSize offset = (geometry.size() - size) / 2;
  46. const QPoint pos = geometry.topLeft() + QPoint(offset.width(), offset.height());
  47. geometry = QRect(pos, size);
  48. }
  49. context->setContextProperty(QStringLiteral("initialX"), geometry.x());
  50. context->setContextProperty(QStringLiteral("initialY"), geometry.y());
  51. context->setContextProperty(QStringLiteral("initialWidth"), geometry.width());
  52. context->setContextProperty(QStringLiteral("initialHeight"), geometry.height());
  53.  
  54. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  55. if (engine.rootObjects().isEmpty())
  56. return -1;
  57.  
  58. return app.exec();
  59. }
To copy to clipboard, switch view to plain text mode