The cross-platform QT framework (KP framework) is used as a graphical toolkit and is also useful when creating CLI applications. It works on three main desktop PCs, on mobile OS (Symbian, Nokia Belle, Meego Harmattan, MeeGo) and on embedded devices capable of perceiving QT interval lengthening.
Program History
QT development was started in 1990 by Norwegian programmers Eirik Chambe-Eng and Haavard Nord. Their company, Trolltech, sold QT licenses and provided technical support. Today, the company is called The QT Company and is a subsidiary of Digia Plc, located in Finland. Although it is the primary driver, software is now being developed by a larger alliance.
It consists of many firms and individuals around the world and works using a meritocratic management model. Anyone who wants to can join the team. There are many ways to make a personal contribution to the QT project. What does the action include? This, for example, writing code or documentation for the framework, reporting errors or helping other users on the forum and supporting the page on the Internet.
Although any build system can be used with the program, it has its own qmake. It is a cross-platform interface for platform-based build systems such as GNU Make, Visual Studio, and Xcode. CMake is also a popular alternative for project development. Not many people know that such a QT is available with different licenses. We are talking about commercial and free software in several versions of the GPL and LGPL.
Support for QT 4 was integrated many years ago, and QT 5 provided software support at an early stage. Recently released a new project - QT Build Suite aka Qbs. It is a QML-based build system that also supports Javascript and CMake packaging.
Integrated Development Environment
The KP framework comes with its integrated development environment (IDE) called QT Creator, runs on Linux, OS X, and Windows. It offers intelligent code completion, syntax highlighting, an integrated help system, debugger, as well as integration for all major version control systems, for example, git, Bazaar. In addition to developing QT Creator on Windows, you can also use the Visual Studio Add-in and other IDEs, such as KDevelop on KDE.
KP structure perfectly supports internationalization (i18n) and localization (l10n). The QT Linguist tool and its companions lupdate, lrelease and lconvert make it easy to translate applications into the required languages. It supports most recording systems in use today. The GUI is created directly in C ++. Note that QT performs this action using the Widgets module. It also comes with the QT Designer interactive graphical tool, which functions as a code generator for Widgets-based graphical interfaces. QT Designer can be used standalone.
GUI development
QTQuick provides the required modules for creating a graphical interface with QML. You can write entire applications only in QML, but, as a rule, the GUI is written in QML, and the backend applications are implemented in C ++. In addition, Creator has a built-in QTQuick graphic designer and profiler.
KP structure is much more than a simple GUI toolkit. It provides modules for cross-platform development in the areas of networks, databases, OpenGL, web technologies, sensors, communication protocols (Bluetooth, serial ports, NFC), XML and JSON processing, printing, PDF generation, QT interval and much more .
Applications that use this software are usually written in C ++, and QML bindings to other languages exist and can be provided by third parties. Riverbank Computing, for example, is the commercial and free software Python bindings (PyQT).
It should be emphasized that such a QT has many attributes that can be changed using getters and setters. If the attribute is called foo, the associated getter and setter will have signatures: T foo () const and void setFoo (const T).
The QT interval extends the system of attributes, getters and setters, which are properties. Specific terminology needs to be clarified. A property is a value of any type that can be accessed, changed or permanent, and also notified of a change. The ownership system is useful, especially in the third part (QML).
Software Class Hierarchy
QT makes extensive use of inheritance, especially in the Widgets module. QObject is a base class. It provides some very powerful features:
- You can set the name as a string to search for objects.
- Parent system
- Signals and slots.
- Event management.
Widgets can respond to events and use the system of parent systems, signals and slots. They inherit from QObject. The simplest widget is QWidget. It contains most of the properties that are used to describe windows or widgets, such as position and size, mouse cursor, and tooltips.
In QT, a widget can also be a window. Thus, there is no need for a QWindow class. Almost all graphic elements are inherited from QWidget:
- QAbstractButton, the base class for all types of buttons.
- QT lengthening scale.
- QPushButton.
- QCheckBox.
- QRadioButton.
- QFrame that displays the frame.
- QLabel that displays text or image.
This inheritance is done to facilitate property management. Some of them, such as size and cursors, may be applicable to other graphic components, and QAbstractButton provides qualities that are shared by all buttons.
Parental control system
This control system is a convenient way to work with objects in QT, especially widgets. Any object that inherits a QObject can have parent and child elements. This hierarchy tree makes work convenient:
- When an object is destroyed, all its parent connections are also removed. Thus, the delete call becomes optional.
- Child widgets in QWidget automatically appear inside the parent.
Almost all user interface tools have a mechanism for detecting an action and react to it.
Signals and Slots
QT provides two high-level concepts: signals and slots. A signal is a message about a change in the status of an object. A slot is a function that is used to receive and respond to a signal.
These concepts are useful for responding to button presses, but they can do much more. For example, they are used to transmit information. Suppose a progress bar is required during song playback to show how much time is left before the sound ends. A media player may have a class that is used to check media progress. An instance of this class may periodically send a signal indicating the value of the change.
A hypothetical class used to check progress can give a signal that has a signature: void MediaProgressManager :: tick (int miliseconds). If the developer connects a signal to a slot that does not use the same parameters, the user will receive a warning: QObject :: connect: Incompatible sender / receiver arguments.
This is due to the fact that the signal transmits information to the slot using certain parameters.
Features of the concepts:
- One signal can be connected to several slots.
- Many signals can be connected to one slot.
- A signal can be connected to another signal - this is called relaying.
- A second signal is sent if the first arrives.
Finding Compilation Issues
When compiling a program, especially in situations where the Q_OBJECT macro is added, an error may occur: main.cpp: undefined reference to vtable for Window '.
This is due to the fact that the compiler does not start in the metaobject class. In this case, qmake restarts by running the Build> Run qmake command. The button is a standard component of the graphical interface of the KP structure. It is often used to make unique choices from a list, for example, in QT QRadioButton for creating switches.
Thanks to its legacy, QRadioButton behaves exactly like QPushButton. All properties are the same. By default, QRadioButtons are not grouped, so many of them can be checked at the same time. To have the "exclusive" behavior of many switches, you need to use the QButtonGroup. This is done as follows: select a new button group and attach it to the parent object. Please note that it may be the main window.
Install SDK for Symbian and Nokia
To start using QT applications, you need to get its library and IDE. They can be created from the source or downloaded as an SDK. They include many features, such as cross-compilers for Symbian and Nokia. Be sure to use these packages:
- QMake Documentation.
- QT documentation.
- QT 4.8.1 Destkop.
- QT Creator.
You can choose other packages if you need development for Symbian / Maemo / Meego, as well as those that have an older version of QT. On Linux, it is better to use the packages that the distribution provides. QT Creator should be available in almost all distributions. When unpacking, it installs all the dependencies, for example, libraries, compilers and development headers.
Now you can create the first window by writing the usual “Hello World”.
Before making the first graphical application, open the Creator IDE for C ++, which is very well suited for coding QT applications. It provides a doc browser and a “designer”, which simplifies the creation of windows. All of them are embedded in a well-designed user interface.
QT is used to indicate which libraries and modules are in the project. Since the first application is usually a small graphical interface, users will need QTCore and QTGui. Now add the entry point of the application. Take a C ++ file or project. The source C ++ file should complete the task. Follow the wizard, setting the file name to main. After that, the project is ready. A new QT line appears in the project file, automatically added by Creator.
QApplication is a very important class. He takes care of the input arguments and the event loop. It is launched when app.exec () is called. To compile this application, click on the green arrow at the bottom left. Creator compiles and lengthens the QT interval. The event loop will start and wait for actions, such as mouse clicks in the graphical interface.
After compilation, the user will see the first QT window. How it will look on the screen is shown in the photo below.
Gmake build system
Creator does the task of invoking the system, but it is important to know how QT programs are compiled. If they are small, it is easy to do this manually by creating object files and then merging them. But for large projects, the command line is difficult to write. On Linux, all programs are compiled using a makefile that describes command lines.
Gmake is the build system that comes with the QT program. It generates makefiles for the developer. Using simple syntax, a file is created that is used to compile the QT program. But this is not the only goal.
QT uses meta objects to extend the functionality of C ++, qmake is responsible for preparing a file that contains this phase of extraction.
QT application compiles in 3 steps:
- The .Pro file is written to describe the project for compilation.
- The make file is created using qmake.
- The program is built using NMake on windows.
Install Creator on Windows
To install the program, go to the official Creator website and download the software. Choose the recommended bootloader:
- QT Online Installer for Windows. Click the "Download" button at the bottom of the page, after which the process begins.
- Launch the QT Creator .exe installer by double-clicking to launch the supplied application, in which it will be installed on the PC.
- For most screens, you can simply click Next to go to the next option.
- On the "Registration" screen, you can click "Skip".
- On the component thief’s screen, they don’t select any versions with the words Alpha, Beta or Preview, but install MinGW.
- Expand the triangle QT, then QT 5.11.2, and then the MinGW 5 .xx 32 bit flag.
If this is not done, the computer will not be able to compile and run C ++ programs.
For all subsequent screens, QT Windows is run:
- Click “Next”, “Agree” or “Install” to complete the installation.
- After that click “Finish” to launch Creator.
- Try to compile / run the sample project.
- To make sure that all parts work correctly, run a project that uses the Stanford C ++ libraries.
- Download the following project ZIP file to your computer: sample-project.zip. It should have a directory named sample-project and several folders inside.
- Open project. In Creator, select “File” → “Open File or Project ...” or press Ctrl + O (Command + O on Mac).
- Go to the sample project folder and open the sample-project.pro file. Creator will ask a few questions about how to set up the build process for this project.
- The user simply accepts the default values and clicks “Configure project”.
Tips for Dummies
To use the program, you need special information about its functions. The most complete documentation package is on the developer's network. It provides DocNotes that can be added by users.
If the QTSDK was installed correctly, the documentation corresponding to the current version of QT should also be installed. You can also use QT Assistant, which is a standalone doc browser.
Important sections of the documentation:
- QT Assistant.
- QT Designer.
- QT Linguist.
- QMake
The most important component is the QT reference documentation. It provides a good introduction to many components. This list is listed on the All Classes page. Another interesting page is the one that lists all the modules. It provides information on the various components.
Class documentation is organized as follows:
- Name and brief description of the class.
- Inheritance.
- Transfers
- Properties
- Social methods.
- Open slots.
- Signals.
- Protected Methods.
Reviews
The number of QT users is increasing annually. Programmers in their reviews not only write that the structure is quite convenient, inexpensive, high-quality, but also explain to beginners all its advantages. Here is some of them:
- The interface is clean and clear. It has all the necessary tools for console output, debugging, tracing, and also includes useful functionality for switching between functions and their definitions.
- The QT functionality for creating, debugging and tracking is extremely useful, especially when the user is trying to find errors in the code of the software product.
- You can easily skip to the section of code that causes the problem to see local variables and their contents in real time.
- The UI / Form Designer is a huge time saver when building complex interfaces. If you do not use it, you will need to manually record the XML manually.
- In QT, its libraries and compilers are easy to save in the profile settings for easy switching and future use.
As you can see, with the help of a cross-platform structure, it is possible to cover all target platforms with one technology and a code base, which minimizes time to market and maintenance load.