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.
-
File System Explorer: A desktop QML app utilizing customized Qt Quick Controls to display text files from a filesystem.
-
Getting Started Programming with Qt Quick: A tutorial for Qt Quick based on an alarms application.
-
Media Player Example: Playing audio and video using Qt Quick.
-
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 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.
-
Same Game: A QML implementation of the popular puzzle game by Kuniaki Moribe.
-
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▲
-
COM App Example (ActiveQt): The COM App example shows how to use ActiveQt to develop a Qt application that can be automated via COM. Different QObject based classes are exposed as COM objects that communicate with the GUI of the running Qt application. The APIs of those COM objects has been designed to resemble the APIs of standard COM applications; i.e. those from Microsoft Office.
-
Media Player Example: Playing audio and video using Qt Quick.
-
Qutlook Example (ActiveQt): The Qutlook example demonstrates the use of ActiveQt to automate Outlook. The example makes use of the dumpcpp tool to generate a C++ namespace for the type library describing the Outlook Object Model.
-
Simple Example (ActiveQt): The Simple example demonstrates the use of QAxBindable and QAxFactory.
-
System Tray Icon Example: The System Tray Icon example shows how to add an icon with a menu and popup messages to a desktop environment's system tray.
-
Taking a Screenshot: The Screenshot example shows how to take a screenshot of the desktop.
-
Wrapper Example (ActiveQt): The Wrapper example demonstrates how to export existing QWidget classes as ActiveX controls, and the use of QAxFactory together with the QAXFACTORY_EXPORT() macro. ActiveX controls in this example are the standard button classes QPushButton, QCheckBox and QRadioButton as provided by Qt.
Mobile▲
-
Calqlatr: A Qt Quick app designed for portrait devices that uses custom components, animated with AnimationController, and JavaScript for the application logic.
-
Charts with QML Gallery: Demonstrates how to use the different chart types by using qml.
-
Coffee Machine: A Qt Quick application with a state-based custom user interface.
-
Hello GLES3 Example: Demonstrates OpenGL ES 3.0 functions via QOpenGLExtraFunctions.
-
Qt Android Notifier: Demonstrates calling Java code from Qt in an Android application.
-
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 - Gallery: A gallery of controls.
-
Qt Quick Controls - Wearable Demo: Demonstrates an application launcher designed for wearable devices.
-
Scene Graph - OpenGL Under QML: Shows how to render OpenGL under a Qt Quick scene.
Embedded▲
-
Coffee Machine: A Qt Quick application with a state-based custom user interface.
-
Qt Quick Controls - Wearable Demo: Demonstrates an application launcher designed for wearable devices.
-
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.
Graphics▲
-
Qt Quick Demo - Clocks: A QML clock application that demonstrates using a ListView type to display data generated by a ListModel and a SpringAnimation type to animate images.
-
Qt Widgets - Text Viewer Plugin Example: A widget example with menus, toolbars and a status bar.
Multimedia▲
-
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.
-
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 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.
-
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.
Data Visualization & 3D▲
-
Audio Samples vs Sound Level: This example shows the drawing of microphone samples vs audio level.
-
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.
-
Cube OpenGL ES 2.0 example: Shows how to manually rotate a textured 3D cube with user input.
-
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.
-
Hello GL2 Example: The Hello GL2 example demonstrates the basic use of the OpenGL-related classes provided with Qt.
-
OpenGL Accelerated Series Example: The example shows how to enable OpenGL acceleration for QLineSeries and QScatterSeries.
-
Qml Oscilloscope: The 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.
-
StocQt: A configurable stock chart for 100 stocks.
-
Zoom Line Example: The example shows how to create your own custom zooming effect.
Data Processing & I/O▲
-
Bindable Properties: Demonstrates how the usage of bindable properties can simplify your C++ code.
-
Books: Shows how to use Qt SQL classes with a model/view framework.
-
Cached SQL Table: The 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.
-
Contiguous Cache Example: The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for very large models. In some environments memory is limited and, even when it isn't, users still dislike an application using excessive memory. Using QContiguousCache to manage a list, rather than loading the entire list into memory, allows the application to limit the amount of memory it uses, regardless of the size of the data set it accesses.
-
DOM Bookmarks Application: Provides a reader for XML Bookmark Exchange Language files.
-
Drill Down Example: The Drill Down example shows how to read data from a database as well as submit changes, using the QSqlRelationalTableModel and QDataWidgetMapper classes.
-
Echo Plugin Example: This example shows how to create a Qt plugin.
-
IPC: Shared Memory: Demonstrates how to share image data between different processes using the Shared Memory IPC mechanism.
-
MIME Type Browser: Shows the hierarchy of MIME types and can be used to determine the MIME type of a file.
-
Mandelbrot: The Mandelbrot example demonstrates multi-thread programming using Qt. It shows how to use a worker thread to perform heavy computations without blocking the main thread's event loop.
-
Master Detail Example: The 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.
-
Prime Counter: Demonstrates how to monitor the progress of concurrent operations.
-
Producer and Consumer using Semaphores: The Producer and Consumer using Semaphores example shows how to use QSemaphore to control access to a circular buffer shared by a producer thread and a consumer thread.
-
Producer and Consumer using Wait Conditions: The Producer and Consumer using Wait Conditions example shows how to use QWaitCondition and QMutex to control access to a circular buffer shared by a producer thread and a consumer thread.
-
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: The 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.
-
Queued Custom Type: The Queued Custom Type example shows how to send custom types between threads with queued signals and slots.
-
Relational Table Model Example: The 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: The 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: The SQL Widget Mapper example shows how to use a map information from a database to widgets on a form.
-
Saving and Loading a Game: How to save and load a game using Qt's JSON or CBOR classes.
-
Serialization Converter: How to convert between different serialization formats.
-
Table Model Example: The Table Model example shows how to use a specialized SQL table model with table views to edit information in a database.
-
Undo Framework Example: This example shows how to implement undo/redo functionality with the Qt undo framework.
-
Word Count: Demonstrates how to use the map-reduce algorithm.
Connectivity▲
-
Annotated URL: Reads formatted NFC Data Exchange Format (NDEF) messages.
-
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.
-
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.
-
Local Fortune Client: Demonstrates using QLocalSocket for a simple local service client.
-
Local Fortune Server: Demonstrates using QLocalServer and QLocalSocket for serving a simple local service.
-
NDEF Editor: Reads and writes NFC Data Exchange Format (NDEF) messages to NFC Forum Tags.
-
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.
-
Simple CoAP Client: Creating an application that communicates with a CoAP server.
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.
-
DTLS client: This example demonstrates how to implement client-side DTLS connections.
-
DTLS server: This examples demonstrates how to implement a simple DTLS server.
-
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.
-
Image Scaling: Demonstrates how to asynchronously download and scale images.
-
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.
-
Qt Quick Demo - RESTful API client: Example of how to create a RESTful API QML client.
-
Secure Socket Client: Demonstrates how to communicate over an encrypted (SSL) connection.
-
Threaded Fortune Server: The 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.
-
Torrent Example: Demonstrates complex TCP/IP operations.
Positioning & Location▲
-
GeoJson Viewer (C++/QML): The 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.
-
Map Viewer (QML): The Map Viewer example shows how to display and interact with a map, search for an address, and find driving directions.
-
MapItemView Transitions (QML): How to use transitions together with MapItemView.
-
Minimal Map (QML): The minimum code to display a map using Qt Quick.
-
Places (QML): The Places example demonstrates how to search for Places and access related content.
-
Places List (QML): The Places List example demonstrates how to search for and display a list of places using a ListView.
-
Places Map (QML): The Places Map example demonstrates how to search for and display a list of places on a map using a MapItemView.
-
Plane Spotter (QML): The Plane Spotter example demonstrates the tight integration of location and positioning data types into QML.
-
SatelliteInfo (C++/QML): The SatelliteInfo example shows the available satellites using Sky View, Table View, or RSSI View and the user's current position.
-
Weather Info (C++/QML): The 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.
User Interface Components▲
-
Address Book: The address book example shows how to use proxy models to display different views onto data from a single model.
-
Arrow Pad Example: Understanding the Qt Linguist contexts concept and using two or more languages.
-
Basic Layouts Example: Shows how to use the standard layout managers.
-
Basic Sort/Filter Model Example: The Basic Sort/Filter Model example illustrates how to use QSortFilterProxyModel to perform basic sorting and filtering.
-
Calculator Example: The example shows how to use signals and slots to implement the functionality of a calculator widget, and how to use QGridLayout to place child widgets in a grid.
-
Calendar Widget Example: The Calendar Widget example shows use of QCalendarWidget.
-
Color Editor Factory Example: This example shows how to create an editor that can be used by a QStyledItemDelegate.
-
Combo Widget Mapper Example: The Combo Widget Mapper example shows how to use a custom delegate to map information from a model to specific widgets on a form.
-
Completer Example: The Completer example shows how to provide string-completion facilities for an input widget based on data provided by a model.
-
Context-Sensitive Help Example: Using the QHelpEngineCore class to implement context-sensitive help for applications.
-
Custom Sort/Filter Model Example: The Custom Sort/Filter Model example illustrates how to subclass QSortFilterProxyModel to perform advanced sorting and filtering.
-
Draggable Icons Example: The Draggable Icons example shows how to drag and drop image data between widgets in the same application, and between different applications.
-
Draggable Text Example: Illustrates how to drag and drop text between widgets.
-
Drop Site Example: The example shows how to distinguish the various MIME formats available in a drag and drop operation.
-
Editable Tree Model Example: This example shows how to implement a simple item-based tree model that can be used with other classes in the model/view framework.
-
Fetch More Example: The Fetch More example shows how to add items to an item view model on demand.
-
Flow Layout Example: Shows how to arrange widgets for different window sizes.
-
Frozen Column Example: This example demonstrates how to freeze a column within a QTableView.
-
Getting Started Programming with Qt Widgets: A tutorial for Qt Widgets based notepad application.
-
Group Box Example: The Group Box example shows how to use the different kinds of group boxes in Qt.
-
Hello tr() Example: Translating a small Hello World program to Latin.
-
I18N Example: Demonstrates Qt's support for translated text.
-
Image Gestures Example: Demonstrates the use of simple gestures in a widget.
-
License Wizard Example: The License Wizard example shows how to implement complex wizards in Qt.
-
Line Edits Example: The Line Edits example demonstrates the many ways that QLineEdit can be used, and shows the effects of various properties and validators on the input and output supplied by the user.
-
Menus Example: The Menus example demonstrates how menus can be used in a main window application.
-
Models and Views: AbstractItemModel Example: Shows how to use a QAbstractItemModel subclass as a model in QML.
-
Models and Views: Object ListModel Example: Shows how to use a QList<QObject*> as a model in QML.
-
Models and Views: String ListModel Example: Shows how to use a QStringList as a model in QML.
-
Order Form Example: The Order Form example shows how to generate rich text documents by combining a simple template with data input by the user in a dialog.
-
PDF Multipage Viewer Example: A Qt Quick PDF viewer that allows scrolling through the pages.
-
PDF Viewer Widget Example: A widget-based PDF viewer that allows scrolling through the pages.
-
QML Dynamic View Ordering Tutorial 1 - A Simple ListView and Delegate:
-
QQuickWidget - QQuickView Comparison Example: Demonstrates the benefits of QQuickWidget over a QQuickView embedded as a native window.
-
QRegularExpression Example: The QRegularExpression example shows how regular expressions in Qt are applied to text by providing an environment in which new regular expressions can be created and tested on custom text strings.
-
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 - Gallery: A gallery of controls.
-
Qt Quick Examples - Pointer Handlers: Shows how to use Qt Quick Input Handlers in interactive components.
-
Qt Quick Examples - Positioners: This is a collection of QML Positioner examples.
-
Qt Quick I18N: Generating translation files (TS and QM) for a Qt Quick application.
-
Qt Quick Layouts - Basic Example: Demonstrates how to use layout types to arrange a UI.
-
Qt Quick Layouts - Responsive Layout Example: Demonstrates how to use LayoutItemProxy to make a responsive UI.
-
Qt Quick Widgets Example: Demonstrates how to mix QML with a Qt Widgets application using the QQuickWidget class.
-
Scribble Example: The Scribble example shows how to reimplement some of QWidget's event handlers to receive the events generated for the application's widgets.
-
Settings Editor Example: The Settings Editor example shows how Qt's standard settings support is used in an application by providing an editor that enables the user to view the settings for installed applications, and modify those that can be edited.
-
Shortcut Editor Example: The Shortcut Editor example shows how to create a basic, read-write hierarchical model to use with Qt's standard view and QKeySequenceEdit classes. For a description of Model/View Programming, see the Model/View Programming overview.
-
Simple Tree Model Example: The Simple Tree Model example shows how to use a hierarchical model with Qt's standard view classes.
-
Sliders Example: The Sliders example shows how to use the different types of sliders available in Qt: QSlider, QScrollBar and QDial.
-
Spin Box Delegate Example: The Spin Box Delegate example shows how to create an editor for a custom delegate in the model/view framework by reusing a standard Qt editor widget.
-
Spin Boxes Example: The Spin Boxes example shows how to use the many different types of spin boxes available in Qt, from a simple QSpinBox widget to more complex editors like the QDateTimeEdit widget.
-
Spreadsheet: The Spreadsheet example shows how to create a simple spreadsheet application.
-
Standard Dialogs Example: The Standard Dialogs example shows the standard dialogs that are provided by Qt.
-
Star Delegate Example: The Star Delegate example shows how to create a delegate that can paint itself and that supports editing.
-
Style Plugin Example: This example shows how to create a plugin that extends Qt with a new GUI look and feel.
-
Syntax Highlighter Example: The Syntax Highlighter example shows how to perform simple syntax highlighting.
-
Tab Dialog Example: The Tab Dialog example shows how to construct a tab dialog using the QTabWidget class.
-
Tablet Example: This example shows how to use a Wacom tablet in Qt applications.
-
Touch Knobs Example: Shows how to create custom controls that accept touch input.
-
Translucent Background: The example shows how to make a round window with a translucent background.
-
Tree Model Completer Example: The Tree Model Completer example shows how to provide completion facilities for a hierarchical model, using a period as the separator to access Child, GrandChild and GrandGrandChild level objects.
-
Trivial Wizard Example: The Trivial Wizard example illustrates how to create a linear three-page registration wizard using three instances of QWizardPage and one instance of QWizard.
-
Troll Print Example: Updating translations for later releases.
-
UI Components: Dial Control Example: The Dial Control Example shows how to create a speedometer-type dial.
-
UI Components: Flipable Example: The Flipable Example shows an item that flips whenever clicked, rotating around the y-axis.
-
Widgets Gallery Example: The Widgets Gallery example shows widgets relevant for designing UIs.
-
Window Flags Example: The Window Flags example shows how to use the window flags available in Qt.
Web Technologies▲
-
HTTP Client: Demonstrates a simple HTTP client.
-
Qt Quick Demo - RSS News: A QML RSS news reader that uses XmlListModel and XmlListModelRole custom QML types to download XML data, ListModel and ListElement to create a category list, and ListView to display the data.
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.