Qt Examples And Tutorials

A collection of code samples and tutorials are provided with Qt to help new users get started with Qt development. These documents cover a range of topics, from basic use of widgets to step-by-step tutorials that show how an application is put together.

The examples are part of the Qt packages. Visit the Downloads page for more information.

Running the Examples

Open and run examples within Qt Creator's Welcome mode. Most of the examples run on various platforms and to search for platform-specific examples, type the platform name (or any keywords) in the search field. For example, typing Android in the search field lists the examples that are fully compatible with Android.

For more information about running examples in Qt Creator, visit the Building and Running an Example page.

Application Examples

Calqlatr

A Qt Quick app designed for portrait devices that uses custom components, animated with AnimationController, and JavaScript for the application logic.

Coffee Machine

A Qt Quick application with a state-based custom user interface.

Dice

A dice throwing application that demonstrates using Qt Quick 3D Physics and Qt Quick 3D.

Document Viewer

A Widgets application to display and print JSON, text, and PDF files.

FX & Material Showroom

Demonstrates material and effects capabilities of Qt Quick 3D. This example demonstrates how you can use particle effects and materials in Qt Quick 3D.

Media Player Example

Playing audio and video using Qt Quick.

Modern File System Explorer

A QML app utilizing customized Qt Quick Controls to display text files from a filesystem

Photo Surface

A QML app for touch devices that uses a Repeater with a FolderListModel to access content in a folder, and a PinchHandler to handle pinch gestures on the fetched content.

Qt Quick Demo - RESTful Color Palette API client

Example of how to create a RESTful API QML client.

Robot Arm Example

Demonstrates how to add a C++ backend to a 3D project from Qt Design Studio. This example demonstrates adding a C++ backend to a 3D project created in Qt Design Studio. The example itself consists of an interactive industrial robot arm in a Qt Quick 3D scene. The 2D UI to control the robot arm is implement using Qt Quick Controls.

Thermostat

A user interface for a home thermostat, implemented in Qt Quick. It demonstrates how to create responsive applications that scale from large desktop displays to mobile and small embedded displays.

To Do List Example

A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform.

Desktop

Calculator Builder

Creating a user interface from a Qt Designer form at run-time

Calculator Form

Using a form created with Qt Designer in an application

Calculator Form/Multiple Inheritance

Using a form created with Qt Designer in an application

Container Extension Example

Creating a custom multi-page plugin for Qt Designer

Custom Widget Plugin

Creating a custom widget plugin for Qt Designer

Media Player Example

Playing audio and video using Qt Quick.

Task Menu Extension

Creating a custom widget plugin for Qt Designer and providing custom task menu entries that are associated with the plugin

Text Finder

Dynamically loading .ui files using QUiLoader

Mobile

In-App purchasing demo

A complete mobile application that demonstrates purchasing in-app products.

Map Viewer (QML)

Map Viewer example shows how to display and interact with a map, search for an address, and find driving directions

Qt Android Notifier

Demonstrates calling Java code from Qt in an Android application

Qt Quick Controls - To Do List

To do list application for iOS

To Do List Example

A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform.

Embedded

Custom Shell

Custom Shell shows how to implement a custom shell extension

Fancy Compositor

Fancy Compositor is an example that demonstrates how to write a fancy Wayland compositor in pure QML

IVI Compositor

IVI Compositor is an example that demonstrates how to use the IviApplication extension

Minimal QML

Minimal QML is a simple example that demonstrates how to write a Wayland compositor in QML

Multi Output

Multi Output is an example that demonstrates a compositor with multiple outputs

Multi Screen

Multi Screen is a desktop-style Wayland compositor for multiple screens

Overview Compositor

Overview Compositor shows how to switch between clients in a grid

Qt Quick Controls - Wearable Demo

Demonstrates an application launcher designed for wearable devices

QtShell Compositor

QtShell Compositor shows how to use the QtShell shell extension

Server Side Decoration Compositor

Server Side Decoration Compositor is a simple example that demonstrates server side window decorations on xdg-shell

Spanning Screens

Spanning Screens is an example that demonstrates how to let Wayland clients span multiple screens

Graphics & Multimedia

Analog Clock

Analog Clock example shows how to draw the contents of a custom widget

Audio Devices Example

Testing the available audio devices and their configuration

Audio Output Example

Enabling audio playback using the QAudioSink class

Audio Recorder Example

Discovering the available devices and supported codecs

Audio Source Example

Recording audio using the QAudioSource class

Camera Example

Shows how to capture a still image or record video. or video

Media Player Example

Playing audio and video

QML Camera Application

This Qt Quick based application shows how to use the API to capture a still image or video

QML Example - Dynamic Scene

This example demonstrates creating components dynamically

QML Media Player Example

Playing audio and video using Qt Quick

QML Video Example

Transforming video and camera viewfinder content

QML Video Recorder

Recording audio and video using Qt Quick

Qt Quick 3D - Custom Instanced Rendering

Demonstrates instancing with custom materials and a C++ instance table

Qt Quick 3D - Particles 3D Testbed Example

Demonstrates how to use the Qt Quick 3D Particles3D module

Qt Quick 3D - Principled Material Example

Demonstrates the use of Principled Material

Qt Quick 3D - Reflection Probes Example

Demonstrates the use of reflection probes in Qt Quick 3D

Qt Quick 3D - Scene Effects Example

Demonstrates the use of ExtendedSceneEnvironment

Qt Quick Controls - Attached Style Properties Example

Demonstrates use of QQuickAttachedPropertyPropagator

Qt Quick Controls - Contact List

A QML app using Qt Quick Controls and a C++ class that implements a simple contact list

Qt Quick Controls - Event Calendar

A simple event calendar

Qt Quick Controls - Flat Style

A QML app using Qt Quick Controls and a QML plugin with customized controls

Qt Quick Controls - Gallery

A gallery of controls

Qt Quick Controls - Imagine Style Example: Automotive

An automotive user interface using custom Imagine style assets

Qt Quick Controls - Text Editor

A QML app using Qt Quick Controls and a C++ class to provide a fully-functional rich-text editor application

Screen Capture Example

Capturing a screen or window

Spatial Audio Panning Example

Shows some of the capabilities of the spatial audio engine in Qt

Spectrum Example

Analyzing a raw audio stream using the FFTReal library

Video Graphics Item Example

Streaming video on a graphics scene

Video Widget Example

Implementing a video player widget

Wiggly

Demonstrates how to use an effect created with the Qt Quick Effect Maker (QQEM)

Data Visualization & 3D

Audio Samples vs Sound Level

This example shows the drawing of microphone samples vs audio level

Axis Handling

Implementing axis dragging with a custom input handler in QML, and creating a custom axis formatter

Charts with QML Gallery

Demonstrates how to use the different chart types by using qml

Charts with Widgets Gallery

An application that demonstrates the Qt Charts Widgets API

Graph Gallery

Gallery of Bar, Scatter, and Surface graphs

Hello Qt Quick 3D Example

Demonstrates simple instanced drawing

Qml Oscilloscope

Example shows how to implement application with strict performance requirements using the Qt Charts QML API

Qml Weather

This is a basic demonstration showing how to use the different chart types by using qml

Qt 3D: Basic Shapes C++ Example

Shows four basic shapes that Qt 3D offers and sets up a mesh for each of them

Qt 3D: Multi Viewport QML Example

A QML example that demonstrates rendering a Scenegraph from multiple viewports

Qt 3D: PBR Materials QML Example

A QML application that demonstrates using PBR materials

Qt 3D: Simple C++ Example

A C++ application that demonstrates how to render a scene in Qt 3D

Qt 3D: Simple Custom Material QML Example

Demonstrates creating a custom material in Qt 3D

Qt 3D: Simple QML Example

A QML application that demonstrates how to render a scene in Qt 3D

Qt 3D: Wireframe QML Example

A Qt 3D QML application that implements a single-pass wireframe rendering method

Qt Quick 3D - Antialiasing Example

Demonstrates the antialiasing modes in Qt Quick 3D

Qt Quick 3D - Baked Lightmap Example

Demonstrates the use of baked lightmaps in a 3D scene

Qt Quick 3D - Custom Effect Example

Demonstrates writing custom post-processing effects

Qt Quick 3D - Custom Geometry Example

Demonstrates providing custom vertex data from C++ and QML

Qt Quick 3D - Custom Instanced Rendering

Demonstrates instancing with custom materials and a C++ instance table

Qt Quick 3D - Custom Materials Example

Demonstrates writing shaded custom materials

Qt Quick 3D - Custom Morphing Animation

Demonstrates writing C++ custom geometry with a morph target

Qt Quick 3D - Custom Shaders Example

Demonstrates the use of custom vertex and fragment shaders

Qt Quick 3D - Dynamic Model Creation Example

Demonstrates dynamic model creation

Qt Quick 3D - HelloCube Example

Demonstrates how to render 2D and 3D objects together in Qt Quick 3D

Qt Quick 3D - Instanced Rendering Example

Demonstrates how to do instanced rendering in Qt Quick 3D

Qt Quick 3D - Introduction

Demonstrates how to render a scene in Qt Quick 3D

Qt Quick 3D - Level of Detail Helper Example

Demonstrates the use of level of detail helper

Qt Quick 3D - Lights Example

Demonstrates the use of different light types

Qt Quick 3D - Morphing Example

Demonstrates how to control morphing animations in Qt Quick 3D

Qt Quick 3D - Particles 3D Testbed Example

Demonstrates how to use the Qt Quick 3D Particles3D module

Qt Quick 3D - Picking example

Demonstrates picking of models

Qt Quick 3D - Principled Material Example

Demonstrates the use of Principled Material

Qt Quick 3D - Procedural Texture Example

Demonstrates how to provide custom texture data from C++ or QML

Qt Quick 3D - Quick Ball Example

Demonstrates how to create a simple game using Quick3D

Qt Quick 3D - Quick Items Example

Demonstrates the use of Qt Quick Items in Quick 3D scene

Qt Quick 3D - Reflection Probes Example

Demonstrates the use of reflection probes in Qt Quick 3D

Qt Quick 3D - RuntimeLoader Example

Demonstrates how assets can be loaded at runtime

Qt Quick 3D - Scene Effects Example

Demonstrates the use of ExtendedSceneEnvironment

Qt Quick 3D - Screen Space Reflections Example

Demonstrates reflections in Qt Quick 3D

Qt Quick 3D - Simple Fog Example

Demonstrates how to enable fog in the 3D scene

Qt Quick 3D - Simple Skinning Example

Demonstrates how to render a simple skinning animation in Qt Quick 3D

Qt Quick 3D - Sub-mesh Example

Demonstrates how assign materials to sub-meshes

Qt Quick 3D - View3D Example

Demonstrates the use of View3D to show a scene from multiple cameras

Qt Quick 3D Physics - Cannon Example

Demonstrates how to spawn physical objects

Qt Quick 3D Physics - CharacterController Example

Demonstrates the CharacterController type

Qt Quick 3D Physics - Compound Shapes Example

Demonstrates using complex collision shapes

Qt Quick 3D Physics - Custom Shapes Example

Demonstrates using different shapes

Qt Quick 3D Physics - Impeller Example

Demonstrates using trigger bodies and collision info

Qt Quick 3D Physics - Mass Example

Demonstrates different ways of setting mass and inertia of a body

Qt Quick 3D Physics - Material Example

Demonstrates using physical materials

Qt Quick 3D Physics - Simple Example

Demonstrates setting up a simple physics scene

Simple Bar Graph

Using Bars3D in a QML application

Simple Scatter Graph

Using Scatter3D in a QML application

Surface Graph Gallery

Gallery with three different ways to use a Surface3D graph

Volumetric Rendering

Rendering volumetric objects

Zoom Line Example

Example shows how to create your own custom zooming effect

Data Processing & I/O

Books

Shows how to use Qt SQL classes with a model/view framework

Cached SQL Table

Cached Table example shows how a table view can be used to access a database, caching any changes to the data until the user explicitly submits them using a push button

Convert Example

Convert example demonstrates how to convert between different serialization formats

DOM Bookmarks Application

Provides a reader for XML Bookmark Exchange Language files

Drill Down Example

Drill Down example shows how to read data from a database as well as submit changes, using the QSqlRelationalTableModel and QDataWidgetMapper classes

JSON Save Game Example

JSON Save Game example demonstrates how to save and load a small game using QJsonDocument, QJsonObject and QJsonArray

Master Detail Example

Master Detail Example shows how to present data from different data sources in the same application. The album titles, and the corresponding artists and release dates, are kept in a database, while each album's tracks are stored in an XML file

Parsing and displaying CBOR data

A demonstration of how to parse files in CBOR format

QXmlStream Bookmarks Example

Demonstrates how to read and write XBEL files

Qt Quick Examples - Local Storage

A collection of QML local storage examples

Query Model Example

Query Model example shows how to make customized versions of data obtained from a SQL query, using a model that encapsulates the query and table views to display the results

Relational Table Model Example

Relational Table Model example shows how to use table views with a relational model to visualize the relations between items in a database

SQL Browser

SQL Browser example shows how a data browser can be used to visualize the results of SQL statements on a live database

SQL Widget Mapper Example

SQL Widget Mapper example shows how to use a map information from a database to widgets on a form

Table Model Example

Table Model example shows how to use a specialized SQL table model with table views to edit information in a database

Connectivity

Annotated URL

Example shows reading from formatted NFC Data Exchange Format (NDEF) messages

Blocking Receiver

Shows how to use the synchronous API of QSerialPort in a non-GUI thread

Blocking Sender

Shows how to use the synchronous API of QSerialPort in a worker thread

Bluetooth Chat

Shows communication through Bluetooth using RFCOMM protocol

Bluetooth Low Energy Heart Rate Game

A game demonstrating the interaction with a Bluetooth Low Energy Heart Rate device/service

Bluetooth Low Energy Heart Rate Server

An example demonstrating how to set up and advertise a GATT service. The example demonstrates the use of the Qt Bluetooth Low Energy classes related to peripheral (slave) functionality

Bluetooth Low Energy Scanner

An application designed to browse the content of Bluetooth Low Energy peripheral devices. The example demonstrates the use of all Qt Bluetooth Low Energy classes

CAN Bus Manager

Example sends and receives CAN bus frames

D-Bus Chat

Demonstrates communication among instances of an application

D-Bus Complex Ping Pong

Demonstrates usage of the Qt D-Bus typesystem

D-Bus Ping Pong

Demonstrates a simple message system using D-Bus

D-Bus Remote Controlled Car

Shows how to use Qt D-Bus to control a car from another application

MQTT Subscriptions

Creating a application that communicates with an MQTT broker

Modbus Client

Example implements a Modbus client application

Modbus Custom Command

Example shows how to handle custom Modbus function codes

Modbus Server

Example implements a Modbus server application

Model-View Client

Developing a very simple client program which displays the content and changes made on a server

Model-View Server

Developing a simple server program that displays and makes changes to a QTreeView which is made available on a Remote Objects network

QtRemoteObjects Bluetooth LE Example

Using QtBluetooth Low Energy (BT LE or BLE for short) as a transport medium with Qt Remote Objects

QtRemoteObjects WebSockets Applications

Using a non-QIODevice-based transport (QWebSocket) with QtRemoteObjects

Quick CoAP Multicast Discovery

Using the CoAP client for a multicast resource discovery with a Qt Quick user interface

Quick Secure CoAP Client

Securing the CoAP client and using it with a Qt Quick user interface

SSL Server and Client

Setting up a secure Remote Object network using QSslSockets

Serial Terminal

Shows how to use various features of QSerialPort

Simple CoAP Client

Creating an application that communicates with a CoAP server

Simple MQTT Client

Creating a minimalistic telemetry application

Time Client Application

A client who holds a replica of a time object from a server and displays the time in a clock

Time Server Application

A server which shares a time object with connected clients

WebSockets MQTT Subscription

Combining an MQTT client with a web socket connection

Networking

A minimal RSS listing application

A demonstration of how to fetch and display a network resource

Blocking Fortune Client

Demonstrates how to create a client for a network service

Chat

Using the Qt GRPC client API in the user applications

Fortune Client

Demonstrates how to create a client for a network service

Fortune Server

Demonstrates how to create a server for a network service

HTTP Client

Demonstrates a simple HTTP client

Magic 8 Ball

Creating a HTTP2 connection between a Qt GRPC client and a C++ gRPC server

Multicast Receiver

Demonstrates how to receive information sent to a multicast group

Multicast Sender

Demonstrates how to send messages to a multicast group

Network Chat

Demonstrates a stateful peer-to-peer Chat client

QML WebSocket Client

Explains how to write a QML WebSocket client example

QML WebSocket Server

A simple example that shows how to use a QML WebSocketServer

Qt Quick Demo - RESTful Color Palette API client

Example of how to create a RESTful API QML client.

Qt WebSockets Examples

List of Qt WebSocket examples

SCXML FTP Client

Implements a simple FTP client using a state machine

Secure WebSocket Echo Client

A simple client application using secure WebSockets (wss)

Secure WebSocket Echo Server

A simple server to respond to clients over secure WebSockets (wss)

Sensors

Sensors example shows how two applications can communicate by sending protobuf messages using UDP sockets

Simple WebSocket Chat

A minimal chat application using the WebSocket protocol

Threaded Fortune Server

Threaded Fortune Server example shows how to create a server for a simple network service that uses threads to handle requests from different clients. It is intended to be run alongside the Fortune Client example

WebSocket Echo Client

Show how to write a simple WebSocket client application

WebSocket Echo Server

Show how to write a simple WebSocket server application

Positioning & Location

GeoJson Viewer (C++/QML)

GeoJson viewer example demonstrates how to manipulate MapItems, handle user input and I/O to and from a GeoJson file

Log File Position Source (C++)

Logfile Position Source shows how to create and work with a custom position source. It can be useful for simulating GPS data, or when the data is received in some custom format

MapItemView Transitions (QML)

How to use transitions together with MapItemView

Minimal Map (QML)

Minimum code to display a map using Qt Quick

Places (QML)

Places example demonstrates how to search for Places and access related content

Places List (QML)

Places List example demonstrates how to search for and display a list of places using a ListView

Places Map (QML)

Places Map example demonstrates how to search for and display a list of places on a map using a MapItemView

Plane Spotter (QML)

Plane Spotter example demonstrates the tight integration of location and positioning data types into QML

SatelliteInfo (QML)

SatelliteInfo example shows the available satellites using Sky View or RSSI View and the user's current position. The satellites currently contributing to the GPS fix are marked as pink

Weather Info (C++/QML)

Weather Info example shows how to use the user's current position to retrieve local content from a web service in a C++ plugin for QML

Web Technologies

Qt WebChannel ChatClient QML Application

A QML client that communicates over a WebSocket with a QWebChannel server

Community Examples

To view and run examples provided through the Qt Project, visit the Community Examples page.

All Examples

All Qt Examples lists all examples categorized by the Qt module they belong to.