Qt Examples And Tutorials | Qt 6.9 (original) (raw)
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.
Open and run examples in Qt Creator 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.
Calqlatr | A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, and JavaScript for the application logic. |
---|---|
Car Configurator | A car model example that demonstrates using Qt Quick 3D cameras, extended scene environment and Qt Quick 3D. |
Coffee Machine | A Qt Quick application with a state-based custom user interface. |
Dice | A dice throwing application using Qt Quick 3D Physics and other Qt Modules. |
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. |
Lightning Viewer | An application with a responsive UI showing lightning strikes on a map in real-time by combining Qt Quick, Qt Location, Qt Positioning and Qt Websockets. |
Media Player | 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. |
QtGrpc Chat | A chat application to share messages of any kind in a chat room |
Robot Arm | 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. |
Satellite Info | Satellite Info example shows the available satellites using Sky View, Table View, or RSSI View and the user's current position. It is implemented with Qt Positioning and Qt Quick |
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 | A QML implementation of to do list application that demonstrates how to create application thats looks native on any platform. |
WebEngine Quick Nano Browser | A web browser implemented using the WebEngineView QML type |
Window Embedding | A demonstration of how to embed non-Qt UI elements into Qt applications. |
COM App Example (ActiveQt) | 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 |
---|---|
Calculator Builder | Creating a user interface from a Qt Widgets Designer form at run-time |
Calculator Form | Using a form created with Qt Widgets Designer in an application |
Calculator Form/Multiple Inheritance | Using a form created with Qt Widgets Designer in an application |
Container Extension Example | Creating a custom multi-page plugin for Qt Widgets Designer |
Custom Widget Plugin | Creating a custom widget plugin for Qt Widgets Designer |
Media Player | Playing audio and video using Qt Quick. |
Qutlook Example (ActiveQt) | 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 |
Remote Control Example | Using and controlling Qt Assistant as a help viewer |
Simple Example (ActiveQt) | Simple example demonstrates the use of QAxBindable and QAxFactory |
Simple Text Viewer Example | Using Qt Assistant as a customized help viewer for your application |
System Tray Icon Example | 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 | Screenshot example shows how to take a screenshot of the desktop |
Task Menu Extension | Creating a custom widget plugin for Qt Widgets Designer and providing custom task menu entries that are associated with the plugin |
Text Finder | Dynamically loading .ui files using QUiLoader |
Wrapper Example (ActiveQt) | 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 |
Calqlatr | A Qt Quick app designed for landscape and portrait devices that uses custom components, responsive layouts, 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. |
Dice | A dice throwing application using Qt Quick 3D Physics and other Qt Modules. |
Hello GLES3 Example | Demonstrates OpenGL ES 3.0 functions via QOpenGLExtraFunctions |
Lightning Viewer | An application with a responsive UI showing lightning strikes on a map in real-time by combining Qt Quick, Qt Location, Qt Positioning and Qt Websockets. |
Map Viewer (QML) | Map Viewer example shows how to display and interact with a map, search for an address, and find driving directions |
Media Player | Playing audio and video using Qt Quick. |
QML Camera Application | This Qt Quick based application shows how to use the API to capture a still image or video |
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 |
Sensors Showcase | Sensors Showcase example demonstrates sensor usage with visual examples |
Coffee Machine | A Qt Quick application with a state-based custom user interface. |
---|---|
Custom Extension | Custom Extension shows how to implement a custom Wayland extension |
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 CPP | Minimal CPP is an example that demonstrates how to write a Wayland compositor in C++ |
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 |
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. |
Virtual Keyboard in Qt Quick | This example shows how to use the virtual keyboard in a Qt Quick application |
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 | 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 |
Calendar Backend Plugin Example | QCalendar example illustrating user-supplied custom calendars |
Contiguous Cache Example | 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 | Drill Down example shows how to read data from a database as well as submit changes, using the QSqlRelationalTableModel and QDataWidgetMapper classes |
Hello Speak Example | Hello Speak example reads out user-provided text |
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 | 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 | 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 |
Models and Views: List Model using a worker thread for data fetching | Demonstrates how to implement a list model with a responsive UI using a worker thread to fetch data |
Move Blocks | Move Blocks example shows how to animate items in a QGraphicsScene using a QStateMachine with a custom transition |
Parsing and displaying CBOR data | A demonstration of how to parse files in CBOR format |
Ping Pong States | Ping Pong States example shows how to use parallel states together with custom events and transitions in Qt State Machine Framework |
Prime Counter | Demonstrates how to monitor the progress of concurrent operations |
Producer and Consumer using Semaphores | 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 | 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 OPC UA Viewer | Using the model/view approach to display all nodes of an OPC UA server in a tree view |
Qt OPC UA X509 Support | Shows how to generate keys and certificate signing requests |
Qt Quick Examples - Local Storage | A collection of QML local storage examples |
Qt Quick Water Pump | Interacting with an OPC UA server to build a QML-based HMI for a simple water pump machine |
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 |
Queued Custom Type | Queued Custom Type example shows how to send custom types between threads with queued signals and slots |
Quick Speech Example | Quick Speech example reads out user-provided text |
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 |
Rogue | Rogue example shows how to use the Qt state machine for event handling |
SCXML Calculator | An application that implements the Calculator example presented in the SCXML Specification |
SCXML Invoke | Invokes a compiled nested state machine |
SCXML Media Player | Sends data to and receives it from a C++ data model |
SCXML Sudoku | Demonstrates the use of separate javascript file with SCXML |
SCXML Traffic Light (Dynamic, QML) | A Qt Quick application that uses a dynamically loaded state machine to implement a traffic light |
SCXML Traffic Light (Dynamic, Widgets) | A widget-based application that uses a dynamically loaded state machine to implement a traffic light |
SCXML Traffic Light (Simple, QML) | A Qt Quick application that uses a compiled state machine to implement a simplified traffic light |
SCXML Traffic Light (Static, QML) | A Qt Quick application that uses a compiled state machine to implement a traffic light |
SCXML Traffic Light (Static, Widgets) | A widget-based application that uses a compiled state machine to implement a traffic light |
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 |
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 | Table Model example shows how to use a specialized SQL table model with table views to edit information in a database |
Traffic Light | Traffic Light example shows how to use Qt State Machine Overview to implement the control flow of a traffic light |
Undo Framework Example | This example shows how to implement undo/redo functionality with the Qt undo framework |
Water Pump | Interacting with an OPC UA server to build a QML-based HMI for a simple water pump machine |
Water Pump Simulation Server | An OPC UA server that implements a simple water pump machine simulation |
Word Count | Demonstrates how to use the map-reduce algorithm |
GeoJson Viewer (QML) | GeoJson viewer example demonstrates how to manipulate MapItems, handle user input and I/O to and from a GeoJson file |
---|---|
Lightning Viewer | An application with a responsive UI showing lightning strikes on a map in real-time by combining Qt Quick, Qt Location, Qt Positioning and Qt Websockets. |
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) | 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) | 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 |
Satellite Info | Satellite Info example shows the available satellites using Sky View, Table View, or RSSI View and the user's current position. It is implemented with Qt Positioning and Qt Quick |
Weather Info | 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 Qt Quick, using Qt Positioning |
Address Book | 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 | Basic Sort/Filter Model example illustrates how to use QSortFilterProxyModel to perform basic sorting and filtering |
Calculator Example | 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 | Calendar Widget example shows use of QCalendarWidget |
Combo Widget Mapper Example | 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 | 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 Completer Example | Custom Completer example shows how to provide string-completion facilities for an input widget based on data provided by a model. The completer pops up suggestions for possible words based on the first three characters input by the user and the user's choice of word is inserted into the TextEdit using QTextCursor |
Custom Sort/Filter Model Example | Custom Sort/Filter Model example illustrates how to subclass QSortFilterProxyModel to perform advanced sorting and filtering |
Draggable Icons Example | 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 | 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 | 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 |
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 | License Wizard example shows how to implement complex wizards in Qt |
Line Edits Example | 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 | 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: Fetch More functionality using a worker thread | Demonstrates how to implement fetchMore() in a worker thread while maintaining a responsive UI |
Models and Views: List Model using a worker thread for data fetching | Demonstrates how to implement a list model with a responsive UI using a worker thread to fetch data |
Models and Views: Object ListModel Example | Shows how to use a QList 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 | 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 Single Page Viewer Example | A Qt Quick PDF viewer that views one page at a time |
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 | |
QML Previewer Example | Demonstrates how to mix QML with a Qt Widgets application using QWidget::createWindowContainer() |
QQuickWidget - QQuickView Comparison Example | Demonstrates the benefits of QQuickWidget over a QQuickView embedded as a native window |
QRegularExpression Example | 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 | Scribble example shows how to reimplement some of QWidget's event handlers to receive the events generated for the application's widgets |
Shortcut Editor Example | 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 | Simple Tree Model example shows how to use a hierarchical model with Qt's standard view classes |
Sliders Example | Sliders example shows how to use the different types of sliders available in Qt: QSlider, QScrollBar and QDial |
Spin Boxes Example | 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 | Spreadsheet example shows how to create a simple spreadsheet application |
Spreadsheets Example | Demonstrates how to create a spreadsheet application |
Standard Dialogs Example | Standard Dialogs example shows the standard dialogs that are provided by Qt |
Star Delegate Example | Star Delegate example shows how to create a delegate that can paint itself and that supports editing |
Syntax Highlighter Example | Syntax Highlighter example shows how to perform simple syntax highlighting |
Tab Dialog Example | 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 | Example shows how to make a round window with a translucent background |
Tree Model Completer Example | 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 | 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 | Dial Control Example shows how to create a speedometer-type dial |
UI Components: Flipable Example | Flipable Example shows an item that flips whenever clicked, rotating around the y-axis |
Widgets Gallery Example | Widgets Gallery example shows widgets relevant for designing UIs |
Widgets Tutorial - Child Widgets | |
Widgets Tutorial - Creating a Window | |
Widgets Tutorial - Nested Layouts | |
Widgets Tutorial - Using Layouts | |
Window Flags Example | Window Flags example shows how to use the window flags available in Qt |
To view and run examples provided through the Qt Project, visit the Community Examples page.