QML, interface description language

Qt Markup Langue is a declarative user interface language. It is compatible with the Qt framework and interacts with its API. It can be extended with C code containing calls to this API.

To use it, the Qt declaration execution time is added to the Qt execution time.

Capture d'écran de démos QML
QML Demo Gallery and Browser

Why use QML

?

Creating an interface for Qt is easier with QML, as it is easier to describe a Java interface with JavaFX that is similar (while other platforms have chosen XML-derived code, such as XAML).
Enough instruction to show "Hello World!" versus seven with Qt, as we see in the list of "Hello World!" in all languages.

However, processing can be much slower than when using direct calls to Qt framework functions, and the language is also better suited for small applications with a simple interface and less for heavier applications. You can also use QML during development and then optimize the target application by moving it to Qt if it is too slow.
It is generally recommended to use QML for mobile devices and QT only on the desktop, without reducing the boot time with QML.

According to the editor, since runtime is installed on the server, the QML application can run on the Web with HTTP, which makes it an alternative to HTML. You can also create an HTML page that appears in your browser and works with JavaScript .

QML has JSON syntax, not XML

Choosing C-inspired syntax allows you to process files faster and reduce size. This is also the JSON principle.

Code examples

Drow has a rectangle with the words "Hello world!"

Rectangle {
   width: 200
   height: 200
   color: mouse.pressed ? "blue" : "red"  
   Text {   
     text: "Salut le Monde!"   
     anchors.centerIn: parent   
   }  
}

Enable JavaScript...

Rectangle {      
   function calculateHeight() 
   {
     ... calculs... 
     return x;      
   }      

   height: calculateHeight()      
   width: { 
      if (height > 100) 200; else 50 
   }  
}  

Learn more at Qt. On the qt-project.org you can find a demonstration showing how to implement the browser interface in QML, with all the necessary widgets.