Fluent-Qt

扩展模块

QmlBridge:嵌入 QML

在 Widgets 应用中嵌入 QML 视图,共享主题 token 和应用模型。

创建视图

链接 FluentQt::QmlBridge,激活 QmlSession 后创建 QmlView。提供给 QML 的模型仍归应用所有。停用会话时会卸载 QML 场景,视图和模型保留。

#include <FluentQt/QmlBridge.h>

// The session uses its own PluginManager; window and models stay caller-owned.
auto* session = new fluent::qmlbridge::QmlSession(window, window);
if (session->activate()) {
    auto* qmlView = session->createView(parentWidget);
    // Load a QML scene into qmlView.
}

图形 API 与主题

Quick 与 SpatialView 或 QOpenGLWidget 共用窗口时,要在创建第一个 Quick 表面之前调用 QmlSession::prepareApplication();激活会话不会选择图形 API。QmlTheme 以只读的 fluentTheme 对象向 QML 提供宿主的主题 token。

API 参考