Qt Quick Widgets

Qt Quick Widgets 模塊是方便包裹器對於 QQuickWindow . It will automatically load and display a QML scene when given the URL of the main qml file. Alternatively, you can instantiate QML objects using QQmlComponent and place them in a manually set-up QQuickWidget .

典型用法:

QQuickWidget *view = new QQuickWidget;
view->setSource(QUrl::fromLocalFile("myqmlfile.qml"));
view->show();
					

QQuickWidget also manages resizing the view and the root item. By default, the resizeMode 被設為 SizeViewToRootObject , which will load the component and resize it to fit the view. Alternatively, you can set resizeMode to SizeViewToRootObject , which will resize the view to the root item.

使用模塊

使用 Qt 模塊的 C++ API 要求直接 (或透過其它依賴) 鏈接到模塊庫。幾個構建工具對此有專用支持,包括 CMake and qmake .

構建采用 CMake

使用 find_package() 命令定位所需模塊組件在 Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS QuickWidgets)
target_link_libraries(mytarget PRIVATE Qt6::QuickWidgets)
					

更多細節,見 構建采用 CMake 概述。

構建采用 qmake quickwidgets

要配置采用 qmake 構建模塊,添加模塊作為值為 QT 變量在工程的 .pro 文件:

QT += quickwidgets
					

參考

許可和歸屬

Qt Quick Widget 在商業許可下是可用的來自 Qt 公司 。此外,它在自由軟件許可下也是可用的。從 Qt 5.4 起,這些自由軟件許可是 GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 瞭解更多細節。