Description #
QML (Qt Modeling Language) is a declarative language designed for building highly dynamic, fluid, and visually appealing user interfaces. It is mainly used with the Qt framework to create cross-platform applications for desktop and embedded systems.
History #
QML was introduced by Nokia in 2009 as part of the Qt Quick framework. It was created to simplify UI development by combining JavaScript with a JSON-like syntax, making it easier to describe UI components and their behaviors declaratively.
Hello World Code #
import QtQuick 2.0
Rectangle {
width: 200
height: 100
color: "lightblue"
Text {
text: "Hello, World!"
anchors.centerIn: parent
}
}
How to Run #
Option 1: Online
Try QML code online at QML Online Editor.
Option 2: Local
- Install Qt from https://www.qt.io/download
- Create a QML file and run it with
qmlscene
command:
qmlscene HelloWorld.qml
Key Concepts #
- Declarative syntax for UI design
- Integrates JavaScript for logic and bindings
- Supports dynamic property bindings and animations
- Cross-platform support (Windows, macOS, Linux, embedded)
- Uses Qt Quick framework for building modern UIs
- Components and states management for responsive designs
- Lightweight and optimized for performance
- Extensible with C++ for backend logic
- Supports touch and gesture input
- Large community around Qt and QML
Try It Online #
Fun Facts #
- QML’s declarative style lets designers and developers work more collaboratively.
- The language was inspired by JSON and JavaScript, making it easy for web developers to learn.
- QML is widely used in automotive infotainment systems and embedded devices.
- The Qt framework powers applications like KDE desktop and Autodesk Maya.
- QML supports state transitions and animations declaratively, reducing the need for imperative code.