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.

To view a list of all Qt examples, visit the List of Qt Examples 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.

Document Viewer

A Widgets application to display and print Json, text and PDF files. Demonstrates various features to use in widget applications: Using QSettings, query and save user preferences, manage file histories and control cursor behavior when hovering over widgets.

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.

Recipe Browser

Injecting custom stylsheets into web pages and providing a rich text preview tool for a custom markup language

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

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

Serial Terminal

Shows how to use various features of QSerialPort

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

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

Embedded

Custom Shell

Custom Shell shows how to implement a custom shell extension

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

Pure QML

Pure QML is an example that demonstrates how to write a Wayland compositor in pure QML

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

Analog Clock

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

Axis Handling

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

Graph Gallery

Gallery of Bar, Scatter, and Surface graphs

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

Wiggly

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

Input/Output

Convert Example

Convert example demonstrates how to convert between different serialization formats

DOM Bookmarks Application

Provides a reader for XML Bookmark Exchange Language files

JSON Save Game Example

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

Parsing and displaying CBOR data

A demonstration of how to parse files in CBOR format

QXmlStream Bookmarks Example

Demonstrates how to read and write to XBEL files

Internationalization

Arrow Pad Example

Understanding the Qt Linguist contexts concept and using two or more languages

Hello tr() Example

Translating a small Hello World program to Latin

I18N Example

Demonstrates Qt's support for translated text

Troll Print Example

Updating translations for later releases

Mobile

In-App purchasing demo

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

Qt Android Notifier

Demonstrates calling Java code from Qt in an Android application

Networking

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

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

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

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

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.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.