35,99 €
Create visually appealing and feature-rich applications by using Qt 5 and the C++ language
Qt 5, the latest version of Qt, enables you to develop applications with complex user interfaces for multiple targets. It provides you with faster and smarter ways to create modern UIs and applications for multiple platforms. This book will teach you to design and build graphical user interfaces that are functional, appealing, and user-friendly.
In the initial part of the book, you will learn what Qt 5 is and what you can do with it. You will explore the Qt Designer, discover the different types of widgets generally used in Qt 5, and then connect your application to the database to perform dynamic operations. Next, you will be introduced to Qt 5 chart which allows you to easily render different types of graphs and charts and incorporate List View Widgets in your application. You will also work with various Qt modules, like QtLocation, QtWebEngine, and the networking module through the course of the book. Finally, we will focus on cross-platform development with QT 5 that enables you to code once and run it everywhere, including mobile platforms.
By the end of this book, you will have successfully learned about high-end GUI applications and will be capable of building many more powerful, cross-platform applications.
This book will appeal to developers and programmers who would like to build GUI-based applications. Basic knowledge of C++ is necessary and the basics of Qt would be helpful.
Lee Zhi Eng is a self-taught programmer who has worked as an artist and programmer at several game studios before becoming a part-time lecturer for 2 years at a university, teaching game development subjects related to Unity and Unreal Engine. He has not only taken part in various projects related to games, interactive apps, and virtual reality, but has also participated in multiple projects that are more oriented toward software and system development. When he is not writing code, he enjoys traveling, photography, and exploring new technologies.Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 308
Veröffentlichungsjahr: 2018
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Richa TripathiAcquisition Editor: Alok DhuriContent Development Editor: Lawrence VeigasTechnical Editor: Mehul SinghCopy Editor:Safis EditingProject Coordinator: Prajakta NaikProofreader: Safis EditingIndexer: Pratik ShirodkarGraphics: Jisha ChirayilProduction Coordinator: Nilesh Mohite
First published: April 2018
Production reference: 1260418
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78839-782-7
www.packtpub.com
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Lee Zhi Eng is a self-taught programmer who has worked as an artist and programmer at several game studios before becoming a part-time lecturer for 2 years at a university, teaching game development subjects related to Unity and Unreal Engine.
He has not only taken part in various projects related to games, interactive apps, and virtual reality, but has also participated in multiple projects that are more oriented toward software and system development. When he is not writing code, he enjoys traveling, photography, and exploring new technologies.
Nibedit Dey is a technopreneur with multidisciplinary technology background. He holds a bachelor's degree in biomedical engineering and a master's degree in digital design and embedded systems. Before starting his entrepreneurial journey, he worked for L&T and Tektronix for several years in different R&D roles. He has been using Qt to build complex software products for the past 8 years. Currently, he is a healthcare innovation fellow at IIT, Hyderabad, and is involved in the development of a new medical device.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Hands-On GUI Programming with C++ and Qt5
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Introduction to Qt
What is Qt?
Why use Qt?
Discovering tools in Qt
Qt Designer
Qt Quick Designer
Downloading and installing Qt
Setting up the working environment
Running our first Hello World Qt program
Summary
Qt Widgets and Style Sheets
Introduction to Qt Designer
Basic Qt widgets
Qt Style Sheets
Summary
Database Connection
Introducing the MySQL database system
Setting up the MySQL database
SQL commands
SELECT
INSERT
UPDATE
DELETE
JOIN
Database connection in Qt
Creating our functional login page
Summary
Graphs and Charts
Types of charts and graphs in Qt
Line and spline charts
Bar charts
Pie charts
Polar charts
Area and scatter charts
Box-and-whiskers charts
Candlestick charts
Implementing charts and graphs
Creating the dashboard page
Summary
Item Views and Dialogs
Working with item view widgets
Creating our Qt Widgets application
Making our List Widget functional
Adding functionality to the Tree Widget
Finally, our Table Widget
Working with dialog boxes
Creating File Selection Dialogs
Image scaling and cropping
Summary
Integrating Web Content
Creating your own web browser
Adding the web view widget
Creating a UI for a web browser
Managing browser history
Sessions, cookies, and cache
Managing sessions and cookies
Managing cache
Integrating JavaScript and C++
Calling JavaScript functions from C++
Calling C++ functions from JavaScript
Summary
Map Viewer
Map display
Setting up the Qt location module
Creating a map display
Marker and shape display
Displaying position markers on a map
Displaying shapes on a map
Obtaining a user's location
Geo Routing Request
Summary
Graphics View
Graphics View framework
Setting up a new project
Movable graphics items
Creating an organization chart
Summary
The Camera Module
The Qt multimedia module
Setting up a new project
Connecting to the camera
Capturing a camera image to file
Recording a camera video to file
Summary
Instant Messaging
The Qt networking module
Connection protocols
Setting up a new project
Creating an instant messaging server
Creating TCP Server
Listening to clients
Creating an instant messaging client
Designing the user interface
Implementing chat features
Summary
Implementing a Graphics Editor
Drawing vector shapes
Vector versus bitmap
Drawing vector shapes using QPainter
Drawing text
Saving vector images to an SVG File
Creating a paint program
Setting up a user interface
Summary
Cloud Storage
Setting up the FTP server
Introducing FTP
Downloading FileZilla
Setting up FileZilla
Displaying the file list on the list view
Setting up a project
Setting up user interface
Displaying the file list
Writing the code
Uploading files to the FTP server
Downloading files from the FTP server
Summary
Multimedia Viewers
Revisiting the multimedia module
Dissecting the module
The image viewer
Designing a user interface for the image viewer
Writing C++ code for image viewers
The music player
Designing a user interface for music players
Writing C++ code for music players
The video player
Designing a user interface for video players
Writing C++ code for video players
Summary
Qt Quick and QML
Introduction to Qt Quick and QML
Introducing Qt Quick
Introducing QML
Qt Quick widgets and controls
Qt Quick Designer
Qt Quick layouts
Basic QML scripting
Setting up the project
Summary
Cross-Platform Development
Understanding compilers
What is a compiler?
Build automation with Make
Build settings
Qt Project (.pro) File
Comment
Modules, configurations, and definitions
Platform-specific settings
Deploying to PC platforms
Windows
Linux
macOS
Deploying to mobile platforms
iOS
Android
Summary
Testing and Debugging
Debugging techniques
Identifying the problem
Print variables using QDebug
Setting breakpoints
Debuggers supported by Qt
Debugging for PC
Debugging for Android devices
Debugging for macOS and iOS
Unit testing
Unit testing in Qt
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Qt 5, the latest version of Qt, enables you to develop applications with complex user interfaces for multiple targets. It provides you with faster and smarter ways to create modern UIs and applications for multiple platforms. This book will teach you how to design and build graphical user interfaces that are functional, appealing, and user-friendly.
By the end of this book, you will have successfully learned about high-end GUI applications and will be capable of building many more powerful, cross-platform applications.
This book will appeal to developers and programmers who would like to build GUI-based applications. Basic knowledge of C++ is necessary, and the basics of Qt would be helpful.
Chapter 1, Introduction to Qt, will give you a tour of Qt. In this book, you'll download the SDK, install Qt, and, most importantly, install Qt Creator, which is used as both the user interface designer and the IDE for writing and compiling C++ scripts.
Chapter 2, Qt Widgets and Style Sheets, will introduce you to the different types of widgets generally used in Qt to develop desktop applications. You will learn the first step to create your own application, which uses all kinds of widgets and customizations, using the powerful style sheet mechanism provided by Qt, which is very similar to CSS for web.
Chapter 3, Database Connection, will introduce you to the MariaDB database and teach you how to connect to it using Qt. You will first learn what is MariaDB database and how to call simple SQL commands to fetch and insert data into a MariaDB database. We will then create a simple but fully functional login page.
Chapter 4, Graphs and Charts, explores the Chart feature to allow users to easily render different types of graphs and charts, such as pie chart, bar chart, and line graph. We will make use of the knowledge learned from this chapter to create a dashboard page for an application, which displays all kinds of statistical summary of their company and business.
Chapter 5, Item Views and Dialogs, will teach you how to display a list of information by using three different item view widgets—a list widget, tree widget, and table widget. You will also learn how to prompt a message box to display error messages, warnings, and confirmation. You will then create an application that can load, scale, and crop images.
Chapter 6, Integrating Web Content, will empower you to use the Qt WebEngine module and make a simple web browser, which displays a web page. We will then go through what is sessions, cookies, and cache and subsequently how to manage them with Qt WebEngine. Finally, you will learn how to make your C++ code communicate with JavaScript content through the WebChannel mechanism.
Chapter 7, Map Viewer, will focus on creating a map display. This map will be used to display the location of places and people. You will learn how to implement the QtLocation module, understand the coordinate system, display location markers on the map, and so on.
Chapter 8, Graphics View, will provide a platform to manage and interact with a large number of custom-made graphical items and a view widget to visualize the items with support for zooming and rotation. You will learn how to make an organization's chart page that displays the structure of an organization and the relationships and relative ranks of its parts and positions/jobs.
Chapter 9, The Camera Module, will explore how to display camera images using Qt. Qt provides us with a multimedia module that enables us to easily take advantage of a platform's multimedia capabilities, such as connecting to the camera of the computer.
Chapter 10, Instant Messaging, will discuss the networking module and help us to make our own simple instant messaging program.
Chapter 11, Implementing a Graphics Editor, is divided into two sections, based on the two types of graphics in the rendering world–bitmap graphics and vector graphics. Both are quite different but essential to learning in order to understand 2D graphics rendering. You will learn how to draw graphics using Qt in this chapter.
Chapter 12, Cloud Storage, will teach you how to upload different types of files to the FTP server and display them in a list. The user will be able to download the file and open them with different types of viewers depending on its file format.
Chapter 13, Multimedia Viewers, will deal with creating a media player instead of using the default software on your computer. In this chapter, you will learn how to create an image viewer, a music player, and a video player.
Chapter 14, Qt Quick and QML, will introduce you to the basics of QML scripting, which is one of the most recent trends in the Qt world.
Chapter 15, Cross-Platform Development, will show you how to export applications to different platforms without re-writing the code from scratch. You will learn some of the essential settings and tips to look out for when porting applications to different platforms. Besides PC platforms, you will also learn how to export applications to mobile platforms.
Chapter 16, Testing and Debugging, will teach you the essentials of how to use various techniques to test and debug your Qt application.
In order to successfully execute all the codes and instructions in this book, you would need the following:
A basic PC/Laptop
A working internet connection
Qt 5.10
MariaDB 10.2 (or MySQL Connector)
Filezilla Server 0.9
We will deal with the installation processes and details as we go through each chapter.
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packtpub.com
.
Select the
SUPPORT
tab.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-GUI-Programming-with-CPP-and-Qt5 In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/HandsOnGUIProgrammingwithCPPandQt5_ColorImages.pdf.
Feedback from our readers is always welcome.
General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packtpub.com.
Qt (pronounced cute) has been used by software engineers and developers for more than two decades to create cross-platform applications since its first release. After several changes of ownership and numerous major code overhauls, Qt has become even more feature rich and supports even more platforms than it used to. Qt not only excels in desktop application development, but is also excellent for both mobile and embedded systems development.
In this chapter, we will cover the following topics :
What is Qt?
Why use Qt?
Using tools in Qt
Downloading and installing Qt
Setting up a working environment
Running our first
Hello World
Qt program
Throughout this chapter, we will learn more about the history of Qt. Then, we'll proceed to build our first example program using the latest version of Qt, which is Qt version 5. For the convenience of our readers, we will simply refer to it as Qt throughout the book.
Currently, the latest version of Qt (as this book is being written) is version 5.10. This version incorporated a lot of new features as well as thousands of bug fixes, which makes Qt a really powerful and stable development kit for software developers and system engineers alike. Qt has a huge package of SDK (software development kit) that contains a wide range of tools and libraries for helping developers get their job done without worrying too much about technical issues related to a specific platform. Qt handles all the messy integration and compatibility issues for you behind the curtain so you don't have to deal with them. This will not only improve efficiency but also reduces development costs, especially when you're trying to develop cross-platform applications that cater to a wider range of users.
There are two types of license for Qt:
The first type is the Open Source License, which is free of charge, but only if your project/product fits their terms and conditions. For example, if you made any changes to the Qt's source code, it is an obligation for you to submit back those changes to Qt developers. Failure to do so could result in serious legal issues, and therefore, you might want to pick the second option instead.
The second type of license is the Commercial License, which gives you full rights to proprietary Qt source code modifications and keeps your application private. But of course, these privileges come with a set of fees.
If you're just starting to learn Qt, don't get pushed back by these terms, as you're certainly not going to modify the source code of Qt libraries or recompile it from source anyway, at least not now.
It's not hard to see why Qt stands a chance of winning against all other existing SDKs out there in the market; first of all, cross-platform compatibility. You can hardly find any other development kits that support so many platforms without writing different sets of code for each platform. By eliminating these extra steps, programmers can just focus on developing their applications without the need to worry about the implementation of each and every platform-specific feature. Furthermore, your code will look clean without all the #ifdef macros and having to load different dependencies for different platforms.
Qt generally uses C++, which is a compiled language that generates small and efficient code. It is also well documented and follows a very consistent set of naming conventions, which reduces the learning curve for the developer.
Do be aware that Qt does include a small amount of features that only work on specific platforms. However, these are minimal and often for special use cases, such as Qt Sensors, which only work on mobile platforms; Qt Web Engine, which only works on desktops; Qt NFC, only for Android and Linux; and so on. Those are some very specific functionalities that only exist on certain platforms that support them. Other than that, common features are usually supported on all platforms.
Qt comes with a set of tools that make programmers' lives easier. One of the tools is Qt Creator (seen in the following screenshot), which is an IDE (integrated development environment) that consists of a code editor and a GUI (graphical user interface) designer that works hand-in-hand with other Qt tools, such as the compiler, debugger, and so on. The most attractive tool among all is, of course, the GUI designer, which comes with two different types of editors: one for widget-based applications, called Qt Designer, and another for Qt Quick Application, called Qt Quick Designer. Both tools can be accessed directly in Qt Creator when you open up a relevant file format. Qt Creator also includes a built-in documentation viewer called Qt Assistant. It is really handy since you can look for the explanation about a certain Qt class or function by simply hovering the mouse cursor over the class name in your source code, and pressing the F1 key. Qt Assistant will then be opened and show you the documentation related to the Qt class or function:
Qt Designer is normally used by developers to design GUIs for desktop applications, while Qt Quick Designer is usually used for mobile and embedded platforms. With that being said, both formats run just fine on both desktop and mobile formats, the only difference is the look and feel, and the types of languages used.
The GUI file saved by Qt Designer carries the .ui extension, which is saved in XML format. The file stores the attributes of each and every widget placed by the GUI designer, such as position, size, margin, tooltip, layout direction, and so on. It also saves the signal-and-slot event names within itself for easily connecting with the code in the later stages. This format does not support coding and only works for Qt C++ projects, namely widget-based application projects.
On the other hand, Qt Quick Designer saves GUI files in both .ui.qml and .qml formats. Qt Quick is a very different type of GUI system in terms of technological concept and development approach, which we will cover in Chapter 14, Qt Quick and QML. Instead of XML format, Qt Quick Designer saves its data in a declarative language similar to JavaScript called QML. QML not only allows the designer to customize their GUI in a CSS-like (Cascading Style Sheets) fashion, it also allows the programmer to write functional JavaScript within the QML file. As we mentioned earlier, .ui.qml is the file format used for visual decoration only while .qml contains application logic.
If you're doing a simple program using Qt Quick, you don't have to touch any C++ coding at all. That's especially welcoming for web developers because they can immediately pick up Qt Quick and develop their own application without a steep learning curve; everything is just so familiar to them. For much more complex software, you can even link C++ functions from QML, and vice versa. Again, if you're interested in learning more about Qt Quick and QML, please head over to Chapter 14, QtQuick and QML.
Since Qt Creator is also written in Qt libraries itself, it is also totally cross-platform. Hence, you can use the same set of tools across different development environments and develop a unified workflow for your team, resulting in better efficiency and cost-effectiveness.
Other than that, Qt comes with many different modules and plugins, which cover a wide range of functionality you need for your projects. There is often no need for you to look for other external libraries or dependencies and try and implement them yourself. The abstraction layer of Qt makes the backend implementation invisible to the users and results in a unified coding style and syntax. If you try to put together a bunch of external dependencies yourself, what you'll find is each library has its own distinctive coding style. It's quite a mess when mixing up all the different coding styles in the same project, unless you make your own abstraction layer, which is a very time-consuming task. Since Qt already includes most, if not all the modules that you need to create feature-rich applications, there is no need for you to implement your own.
That being said, there are also many third libraries out there that extend Qt for features that Qt itself does not support, such as libraries that focus on game development or any other features that are designed for the specific user group.
Without wasting any time, let's begin with our installation! To get the free installer for Open Source Qt, first go to their website at https://www.qt.io. There, look for the button that says Download Qt (the website might look different if they have updated it). Do note that you might be downloading the free trial version for the Commercial Qt, which you cannot use after 30 days. Make sure that you are downloading the open source version of Qt instead. Also, you may want to pick the right installer for your platform, since there are many different installers of Qt for different operating systemsWindows, macOS, and Linux.
You might wonder why the installer is so small in size—it is only around 19 MB. This is because the unified online installer doesn't actually contain any of the Qt packages, but is rather a downloader client which helps you to download all the relevant files and install them to your computer once the download has completed. Once you have downloaded the online installer, double-click on it and you will be presented with an interface like this (the following example is running on a Windows system):
Click the Next button, and a DRM (Digital Rights Management) page will appear and ask you to log in with your Qt account. If you don't have one, you can also create your account on the same page:
Once you have logged in, you will see a message that says No valid commercial license available in your Qt Account for this host platform. Don't worry about that, just click the Next button to proceed.
Next, you will be asked to specify the installation path. The default path is usually just fine, but you can change it to any other path as you please. Also, you can either leave the Associate this common file types with Qt Creator option checked, or uncheck it manually if otherwise.
After that, you will be presented with a series of checkboxes with which you can select the version(s) of Qt you need to install to your computer. Typically, for new users, the default options are sufficient. If you don't need some of the options, such as support for Qt on Android, you can unselect them here to reduce the size of the download. You can always go back and add or remove Qt components later if needed, using the Maintenance Tool:
Next, you will be presented with the license agreement. Check the first option, which says I have read and agree to the terms contained in the license agreements, and click the Next button. Make sure you do read the terms and conditions stated in the license agreement!
Finally, the installer will ask you to enter a name to create a start menu shortcut for Qt. Once you're done, just click Next and then click Install. The download process will take a couple of minutes to a couple of hours, depending on your internet speed. Once all the files have been downloaded, the installer will automatically proceed to install the files to the installation path that you have just set in one of the previous steps.
Since you have installed the latest version of Qt, let's fire up Qt Creator and start messing around by creating our first project! You should be able to find Qt Creator's shortcut icon either on your desktop or somewhere within your start menu.
Let's look at the steps to set up our environment:
When you first start Qt Creator, you should see the following interface:
Before you start creating your first project, there are several settings that you might want to tweak. Go to the top menu and select
Tools
|
Options
. A window that looks something like this will pop up on the screen:
There are quite a number of different categories available on the left of the window. Each category represents a set of options you can set to customize how Qt Creator will look and operate. You may not want to touch the settings at all, but it's good to learn about them first. One of the first settings you might want to change is the
Language
option, which is available in the
Environment
category. Qt Creator provides us with an option to switch between different languages. Although it doesn't support all languages, most of the popular ones are available, such as English, French, German, Japanese, Chinese, Russian, and so on. Once you have selected your desired language, click
Apply
and restart Qt Creator. You must restart Qt Creator in order to see the changes.
The next setting you probably need is the setting for indentation. By default, Qt uses
space indentation
, in which four spaces will be added to your script whenever you press the
Tab
key on your keyboard. Some people, like me, prefer
tab indentation
instead. You can change the indentation setting at
C++ category
.
Under the C++ category, you can find a
Copy
button located beside the
Edit
button, somewhere in the top right position. Click it and a new window will pop up.
Insert a code style name of your own, as you can't edit the default built-in coding style. After you have created your own settings, click the
Edit
button. You can now see the actual
Tabs And Indentation
settings under the
General
tab:
Do note that even though there is a
Tabs And Indentation
setting located at the
Text Editor
category, I believe it's an old setting that no longer has any effect in Qt Creator. There is also a note written on the UI that says
Code indentation is configured in C++ and Qt Quick settings
. A possible reason for this is that since Qt Creator now supports both C++ project and QML projects, Qt developers probably felt there was a need to separate the settings into two, so therefore the old setting is no longer valid. I'm pretty sure this section on Text Editor will be deprecated in the near future.
Next, under the
Build and Run
category, you'll see a tab labeled
Kits
.
This is where you can set the compile settings for each platform. As you can see from the next screenshot, my Qt does not support desktop build under MSVC (Microsoft Visual Studio Compiler) because I never installed Visual Studio on my computer. Instead, my Qt only supports desktop build under the MinGW (Minimal GNU for Windows) compiler. From this window, you can check and see if your Qt supports the platform and compiler you wanted for your project and make changes to it if necessary. But for now, we'll just leave it as it is. To learn more about what is a
kit
is and how to configure the build settings, please head over to
Chapter 15
,
Cross-Platform Development
:
Finally, we can link our project to our version control server at the
Version Control
category.
Version control allows you or your team to submit code changes to a centralized system so that each and every team member can obtain the same code without passing files around manually. When you're working in a big team, it's very difficult to manually keep track of the code changes, and even more so to merge the code done by different programmers. Version control systems are designed to solve these issues. Qt supports different types of version control systems, such as Git, SVN, Mercurial, Perforce, and so on. Although this is a very useful feature, especially if you're working in a team, we don't need to configure it for now:
A Hello World program is a very simple program that does nothing more than display an output that says Hello, World! (or any other thing, not necessarily this) to show that the SDK is working properly. We don't need to write very long code to produce a Hello World program, we can do it using only the very minimum and the most basic code. In fact, we don't have to write any code in Qt, as it will generate the code when you first create your project!
Let's begin our project by following these steps:
To create a new project in Qt, click the
New Project
button located at the welcome screen on your Qt Creator. Alternatively, you can also go to the top menu and select
File
|
New File or Project
.
