main.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware)
  2. // Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao)
  3. // SPDX-License-Identifier: Apache-2.0
  4. #include <QtGui/QGuiApplication>
  5. #include <QtQml/QQmlApplicationEngine>
  6. #include <QtQml/QQmlContext>
  7. #include <QtQuick/QQuickWindow>
  8. #include <QWKQuick/qwkquickglobal.h>
  9. #ifdef Q_OS_WIN
  10. // Indicates to hybrid graphics systems to prefer the discrete part by default.
  11. extern "C" {
  12. Q_DECL_EXPORT unsigned long NvOptimusEnablement = 0x00000001;
  13. Q_DECL_EXPORT int AmdPowerXpressRequestHighPerformance = 1;
  14. }
  15. #endif
  16. int main(int argc, char *argv[]) {
  17. qputenv("QT_WIN_DEBUG_CONSOLE", "attach"); // or "new": create a separate console window
  18. qputenv("QSG_INFO", "1");
  19. qputenv("QSG_NO_VSYNC", "1");
  20. #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
  21. qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
  22. #else
  23. qputenv("QT_QUICK_CONTROLS_STYLE", "Default");
  24. #endif
  25. //qputenv("QSG_RHI_BACKEND", "opengl"); // other options: d3d11, d3d12, vulkan
  26. //qputenv("QSG_RHI_HDR", "scrgb"); // other options: hdr10, p3
  27. //qputenv("QT_QPA_DISABLE_REDIRECTION_SURFACE", "1");
  28. #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
  29. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
  30. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  31. #endif
  32. QGuiApplication application(argc, argv);
  33. // Make sure alpha channel is requested, our special effects on Windows depends on it.
  34. QQuickWindow::setDefaultAlphaBuffer(true);
  35. QQmlApplicationEngine engine;
  36. #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
  37. const bool curveRenderingAvailable = true;
  38. #else
  39. const bool curveRenderingAvailable = false;
  40. #endif
  41. engine.rootContext()->setContextProperty(QStringLiteral("$curveRenderingAvailable"), QVariant(curveRenderingAvailable));
  42. QWK::registerTypes(&engine);
  43. engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
  44. return application.exec();
  45. }