Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Cross-Platform Development with Qt 6 and Modern C++

You're reading from  Cross-Platform Development with Qt 6 and Modern C++

Product type Book
Published in Jun 2021
Publisher Packt
ISBN-13 9781800204584
Pages 442 pages
Edition 1st Edition
Languages
Author (1):
Nibedit Dey Nibedit Dey
Profile icon Nibedit Dey

Table of Contents (17) Chapters

Preface 1. Section 1: The Basics
2. Chapter 1: Introduction to Qt 6 3. Chapter 2: Introduction to Qt Creator 4. Chapter 3: GUI Design Using Qt Widgets 5. Chapter 4: Qt Quick and QML 6. Section 2: Cross-Platform Development
7. Chapter 5: Cross-Platform Development 8. Section 3: Advanced Programming, Debugging, and Deployment
9. Chapter 6: Signals and Slots 10. Chapter 7: Model View Programming 11. Chapter 8: Graphics and Animations 12. Chapter 9: Testing and Debugging 13. Chapter 10: Deploying Qt Applications 14. Chapter 11: Internationalization 15. Chapter 12: Performance Considerations 16. Other Books You May Enjoy

Creating a simple M/V application with Qt Quick

In earlier sections, we discussed Qt's Model-View-Delegate framework. You learned how to create a custom Model and delegate and how to use a C++ Model. But you must be wondering how to integrate with our QML frontend. In this section, we will create a C++ Model and expose it to the QML engine. We will also discuss how to register a custom Model as a QML type.

Let's create an application that fetches a Model from the C++ code and displays it in a Qt Quick-based application:

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QStringListModel>
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    QStringList stringList;
    stringList << "Item 1" << "Item 2" << "Item 3" 
 ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}