Qt QML Reference Documentation

Extending QML - Adding Types Example

Declare the Person Class

Define the Person Class

Running the Example

Extending QML - Attached Properties Example

Extending QML - Binding Example

Extending QML - Inheritance and Coercion Example

Declare Boy and Girl

Define People as a base class

Define Boy and Girl

Running the Example

Extending QML - Default Property Example

Declaring the BirthdayParty Class

Running the Example

Extending QML - Extension Objects Example

Extending QML - Grouped Properties Example

Extending QML - Methods Example

Extending QML - Object and List Property Types Example

Declare the BirthdayParty

Define the BirthdayParty

Running the Example

Extending QML - Signal Support Example

Extending QML - Property Value Source Example

QML Example - Dynamic Scene

C++ Extensions: Network Access Manager Factory Example

QML Examples - Internationalization

QML Plugin Example

Qt Quick Examples - XMLHttpRequest

Running the Example

Get Data

FinalState

Example Usage

QAbstractTransition

QSignalTransition

SignalTransition

Example Usage

HistoryState

Example Usage

QAbstractState

State

States with Child States

Example Usage

StateMachine

Example Usage

TimeoutTransition

Example Usage

Important C++ Classes Provided By The Qt QML Module

QML Runtime

The QQmlEngine Class

The QQmlContext Class

Dynamic Object Instantiation and Expression Evaluation

The QQmlComponent Class

The QQmlExpression Class

Usage of the Classes within QML Applications

Embedding C++ Objects into QML with Context Properties

Setting a Simple Context Property

Setting an Object as a Context Property

Data Type Conversion Between QML and C++

Data Ownership

Basic Qt Data Types

QObject-derived Types

Conversion Between Qt and JavaScript Types

QVariantList and QVariantMap to JavaScript Array and Object

QDateTime to JavaScript Date

Sequence Type to JavaScript Array

Value types

Enumeration Types

Enumeration Types as Signal and Method Parameters

Defining QML Types from C++

Registering C++ Types with the QML Type System

Registering an Instantiable Object Type

Registering Non-Instantiable Types

Registering Singleton Objects with a Singleton Type

Type Revisions and Versions

Registering Extension Objects

Defining QML-Specific Types and Attributes

Providing Attached Objects for Data Annotations

Steps for Implementing Attached Objects

Implementing Attached Objects: An Example

Property Modifier Types

Property Value Sources

Specifying Default Properties for QML Object Types

Defining Visual Items with the Qt Quick Module

Receiving Notifications for Object Initialization

Exposing Attributes of C++ Types to QML

Data Type Handling and Ownership

Exposing Properties

Notes on Use of Notify Signals

Properties with Object Types

Properties with Object-List Types

Grouped Properties

Exposing Methods (Including Qt Slots)

Exposing Signals

Writing QML Extensions with C++

Running the Tutorial Examples

Chapter 1: Creating a New Type

Chapter 2: Connecting to C++ Methods and Signals

Chapter 3: Adding Property Bindings

Chapter 4: Using Custom Property Types

Chapter 5: Using List Property Types

Chapter 6: Writing an Extension Plugin

Chapter 7: Summary

Interacting with QML Objects from C++

Loading QML Objects from C++

Accessing Loaded QML Objects by Object Name

Accessing Members of a QML Object Type from C++

Properties

Invoking QML Methods

Connecting to QML Signals

Integrating QML and C++

Exposing Attributes of C++ Classes to QML

Defining QML Types from C++

Embedding C++ Objects into QML with Context Properties

Interacting with QML Objects from C++

Data Type Conversion Between QML and C++

Qt5 Cadaques

ECMA-262

W3Schools JavaScript Reference

Mozilla Developer Network Date Reference

Date

Dynamic QML Object Creation from JavaScript

Creating Objects Dynamically

Creating a Component Dynamically

Creating an Object from a String of QML

Maintaining Dynamically Created Objects

Deleting Objects Dynamically

JavaScript Expressions in QML Documents

JavaScript in Property Bindings

JavaScript in Signal Handlers

JavaScript in Standalone Functions

JavaScript in Custom Object Methods

Functions in Imported JavaScript Files

Connecting Signals to JavaScript Functions

JavaScript in Application Startup Code

List of JavaScript Objects and Functions

The Global Object

Value Properties

Function Properties

Constructor Properties

Other Properties

The Object Object

Object Constructor

Function Properties

Object Prototype

Function Properties

Function Objects

Function Prototype

Function Properties

Array Objects

Array Prototype Object

Function Properties

String Objects

String Prototype Object

Function Properties

Boolean Objects

Boolean Prototype Object

Function Properties

Number Objects

Number Prototype Object

Function Properties

The Math Object

Value Properties

Function Properties

Date Objects

Date Prototype Object

Function Properties

RegExp Objects

RegExp Prototype Object

Function Properties

Error Objects

Error Prototype Object

Value Properties

Function Properties

The JSON Object

Function Properties

JavaScript Host Environment

Common Base

QML Global Object

JavaScript Objects and Functions

JavaScript Environment Restrictions

Importing JavaScript Resources in QML

Importing a JavaScript Resource from a QML Document

Imports Within JavaScript Resources

Importing a JavaScript Resource from Another JavaScript Resource

Importing a QML Module from a JavaScript Resource

Including a JavaScript Resource from Another JavaScript Resource

Number

QML Global Object

XMLHttpRequest

XMLHttpRequest

Making Applications Scriptable

Scripting Classes

Basic Usage

Making a QObject Available to the Script Engine

Defining JavaScript Resources In QML

Code-Behind Implementation Resource

Shared JavaScript Resources (Libraries)

String

Integrating QML and JavaScript

JavaScript Expressions

JavaScript Resources

JavaScript Imports

JavaScript Host Environment

Defining Object Types through QML Documents

Defining an Object Type with a QML File

Importing Types Defined Outside the Current Directory

Accessible Attributes of Custom Types

Resource Loading and Network Transparency

Relative vs. Absolute URLs

QRC Resources

Limitations

Implications for Application Security

Scope and Naming Resolution

JavaScript Scope

Type Names and Imported JavaScript Files

Binding Scope Object

Component Scope

Component Instance Hierarchy

Overridden Properties

JavaScript Global Object

Structure of a QML Document

Imports

The Root Object Declaration

QML Documents

Structure of a QML Document

Syntax of the QML Language

Defining Object Types through QML Documents

Resource Loading and Network Transparency

Scope and Naming Resolution

Creating C++ Plugins for QML

Creating a Plugin

Plugin Example

Reference

Identified Modules

Locally Installed Identified Modules

An Example

Remotely Installed Identified Modules

Semantics of Identified Modules

Legacy Modules

Installed Legacy Modules

Located Legacy Modules

Module Definition qmldir Files

Contents of a Module Definition qmldir File

Versioning Semantics

Example of a qmldir File

Writing a qmltypes File

QML Modules

Defining a QML Module

Supported QML Module Types

Providing Types and Functionality in a C++ Plugin

The QML Reference

QML Syntax Basics

Import Statements

Object Declarations

Child Objects

Comments

Importing QML Document Directories

Local Directory Imports

An Example

Remotely Located Directories

Directory Listing qmldir Files

Import Statements

Syntax of an Import Statement

Import Types

Module (Namespace) Imports

Non-module Namespace Imports

Importing into a Qualified Local Namespace

Directory Imports

JavaScript Resource Imports

JavaScript Resources from Modules

Further Information

QML Import Path

Debugging

QML Object Attributes

Attributes in Object Declarations

The id Attribute

Property Attributes

Defining Property Attributes

Valid Types in Custom Property Definitions

Assigning Values to Property Attributes

Value Assignment on Initialization

Imperative Value Assignment

Static Values and Binding Expression Values

Type Safety

Special Property Types

Object List Property Attributes

Grouped Properties

Property Aliases

Considerations for Property Aliases

Default Properties

Read-Only Properties

Property Modifier Objects

Signal Attributes

Defining Signal Attributes

Property Change Signals

Signal Handler Attributes

Property Change Signal Handlers

Method Attributes

Defining Method Attributes

Attached Properties and Attached Signal Handlers

A Note About Accessing Attached Properties and Signal Handlers

Property Binding

Overview

Creating Property Bindings from JavaScript

Using <@keyword>this</@keyword> with Property Binding

Signal and Handler Event System

Receiving Signals with Signal Handlers

Property Change Signal Handlers

Using the Connections Type

Attached Signal Handlers

Adding Signals to Custom QML Types

Connecting Signals to Methods and Signals

Signal to Signal Connect

QML Basic Types

Supported Basic Types

Basic Types Provided By The QML Language

Basic Types Provided By QML Modules

Property Change Behavior for Basic Types

Using the enumeration Type in QML

Using the list Type

Using the url Type

Change Notification Semantics

Property Value Initialization Semantics

Using Scarce Resources with the variant Type

Storing Arrays and Objects

QML Object Types

Defining Object Types from QML

Defining Object Types through QML Documents

Defining Anonymous Types with Component

Defining Object Types from C++

The QML Type System

Basic Types

JavaScript Types

QML Object Types

Qt QML

Getting Started

QML and QML Types

Lists and Models

JavaScript Environment for QML Applications

Integrating QML with C++ Applications

Additional Frameworks

Guides and Other Information

Reference

The Declarative State Machine Framework

Using both QtQuick and QtQml.StateMachine imports

A Simple State Machine

State Machines That Finish

Sharing Transitions

Using History States

Using Parallel States

Exiting a Composite State

Targetless Transitions

Related Information

Evaluating Scripts

Engine Configuration

Script Exceptions

Script Object Creation

QObject Integration

Extensions

Component

Creation Context

Network Components

The Context Hierarchy

Qt

QmlGlobalQtObject

Enums

Types

Date/Time Formatters

Dynamic Object Creation

Other Functions

QtObject

Plugin Example

Locale

FormatType

Locale String Format Types

Binding

Binding to an inaccessible property

Conditional bindings

Connections

DelegateModel

DelegateModelGroup

VisualDataGroup

VisualDataModel

Instantiator

QModelIndex and related Classes in QML

QModelIndex and QPersistentModelIndex Types

QModelIndexList Type

QItemSelectionRange Type

QItemSelection Type

ItemSelectionModel

ListElement

Referencing Roles

Example Usage

ListModel

Example Usage

Modifying List Models

Using Threaded List Models with WorkerScript

ObjectModel

VisualItemModel

Timer

Package

WorkerScript

Restrictions

Qt QML Examples

Scripting Classes and Overviews

Qt QML C++ Classes

Qt QML QML Types

Importing QtQml

Basic Types

Object Types

Qt QML Models QML Types

Declarative State Machine QML Types