This article is a introductory tutorial for the Qt language.
Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases Qt is classified as a widget toolkit), and also used for developing non-GUI programs such as command-line tools and consoles for servers.
Qt uses standard C++ but makes extensive use of a special code generator (called the Meta Object Compiler, or moc) together with several macros to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on the major desktop platforms and some of the mobile platforms. It has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support, and a unified cross-platform application programming interface (API) for file handling.
[Extracted from the Wikipedia]
In QT a slot is the receiver from a signal or an a event (like mouse click on a button)
To create a slot for a widget in QT designer:
Later you will see a new function, this is an slot.
When you click the button the slot will be activated and the code executes.
A signal is a special callback to call a defined slot. You can define signals between dialogs:
The first is to create a new slot, for example textValue (defined in the receiver .h file)
Later write this method in the .cpp receiver file
The next step is to define the sender signal in the .h
Now in the sender dialog define the caller slot
In this slot we will use "emit" to send the signal
To link the receiver slot and the sender signal we must to add a connect to the dialog object.
To make a good layout and a good resizing:
Use the "spacer" and use the horizontal layout to align widgets.
Later we need an a vertical layout to finish the align.
By default the centralWidget don't have a layout
As our application main layout is vertical we select it for MainWindow.
Now uses the vercial layout
The app is well aligned
To have a good resizing policy we must select "sizePolicy" to Expanding
The designer is very limited on the toolbar management, and we must to code:
Remember to delete all objects in the dialog destructor.
We created a new dialog, but... ¿How show it?
Define the dialog (modal) and use exec()
The first is to create a new resource file
Add: QT -> QT resource file
It will be in the Resources project section
Later is possible to add a file to it