Merge pull request #197 from mentalfl0w/qt-5.15.2-dev

Fix the bug of static resources didn't imported by engine.
This commit is contained in:
zhuzichu 2023-07-11 09:56:03 +08:00 committed by GitHub
commit 6e88287e3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,11 @@ file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
#
add_definitions(-DVERSION=1,3,7,3)
#FluentUI
if(FLUENTUI_BUILD_STATIC_LIB)
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
endif()
find_package(Qt5 REQUIRED COMPONENTS Quick)
set(CMAKE_AUTOMOC ON)

View File

@ -10,7 +10,9 @@
#include "AppInfo.h"
FRAMELESSHELPER_USE_NAMESPACE
#ifdef FLUENTUI_BUILD_STATIC_LIB
Q_IMPORT_PLUGIN(FluentUIPlugin)
#endif
int main(int argc, char *argv[])
{
//将样式设置为Basic不然会导致组件显示异常
@ -38,6 +40,10 @@ int main(int argc, char *argv[])
app.setQuitOnLastWindowClosed(false);
QQmlApplicationEngine engine;
FramelessHelper::Quick::registerTypes(&engine);
#ifdef FLUENTUI_BUILD_STATIC_LIB
qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_FluentUIPlugin().instance())->initializeEngine(&engine, "FluentUI"); // 让静态资源可以被QML引擎搜索到
//qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_FluentUIPlugin().instance())->registerTypes("FluentUI");
#endif
qmlRegisterType<CircularReveal>("example", 1, 0, "CircularReveal");
appInfo->init(&engine);
const QUrl url(QStringLiteral("qrc:/example/qml/App.qml"));