QML 是允許就視覺組件、交互、彼此關係,描述用戶界麵的聲明性語言。它是旨在使組件能夠以動態方式互連,並允許組件在用戶界麵內被輕鬆重用和定製的高度可讀語言。使用
QtQuick
模塊,設計人員和開發人員可以輕鬆采用 QML 構建動畫流暢的 UI (用戶界麵),和擁有把這些用戶界麵連接到任何後端 C++ 庫的選項。
QML 是用戶界麵規範和編程語言。它讓開發人員和設計人員同樣都能創建高性能、動畫流暢、視覺吸引人的應用程序。QML 提供高度可讀、聲明式、像 JSON 的語法,支持命令式 JavaScript 錶達式結閤動態特性綁定。
import QtQuick import QtQuick.Controls ApplicationWindow { width: 400 height: 400 visible: true Button { id: button text: "A Special Button" background: Rectangle { implicitWidth: 100 implicitHeight: 40 color: button.down ? "#d6d6d6" : "#f6f6f6" border.color: "#26282a" border.width: 1 radius: 4 } } }
QML 語言和引擎基礎設施的提供是通過 Qt QML 模塊。有關 QML 語言的深入信息,請參閱 Qt QML 模塊文檔編製。
以下頁麵包含有關 QML 的更多信息:
Qt Quick is the standard library of QML types and functionality for QML. It includes visual types, interactive types, animations, models and views, particle effects and shader effects. A QML application developer can get access to all of that functionality with a single import statement.
The
QtQuick
QML 庫的提供是通過
Qt Quick
模塊。有關 Qt Quick 提供的各種 QML 類型和其它功能的深入信息,請參閱
Qt Quick
module documentation. Qt Quick adds visual types, animation types, and other QML types in addition to the standard QML types from Qt QML.
For a set of UI controls, the Qt Quick Controls 模塊實現如按鈕、菜單及視圖的幾個控件。這些控件帶有幾種可以使用的內置樣式,且還支持創建自定義樣式。
Qt Creator sets up project environments for the following types of Qt Quick applications:
For more information about Qt Quick applications, visit the following pages:
要瞭解有關 QML 代碼使用的更多信息,有幾個代碼樣本展示如何使用 QML 類型。此外,還有幾個演示展示如何在應用程序中使用 QML 代碼。