Book Image

Getting Started with Qt 5

By : Benjamin Baka
Book Image

Getting Started with Qt 5

By: Benjamin Baka

Overview of this book

Qt is a cross-platform application framework and widget toolkit that is used to create GUI applications that can run on different hardware and operating systems. The main aim of this book is to introduce Qt to the reader. Through the use of simple examples, we will walk you through building blocks without focusing too much on theory. Qt is a popular tool that can be used for building a variety of applications, such as web browsers, media players such as VLC, and Adobe Photoshop. Following Qt installation and setup, the book dives straight into helping you create your first application. You will be introduced to Widgets, Qt's interface building block, and the many varieties that are available for creating GUIs. Next, Qt's core concept of signals and slots are well illustrated with sufficient examples. The book further teaches you how to create custom widgets, signals and slots, and how to communicate useful information via dialog boxes. To cap everything off, you will be taken through writing applications that can connect to databases in order to persist data. By the end of the book, you should be well equipped to start creating your own Qt applications and confident enough to pick up more advanced Qt techniques and materials to hone your skills.
Table of Contents (8 chapters)

Widgets

Widgets are the graphical components with which we construct user interfaces. A familiar example of such a component is a textbox. This is the component that is used to capture our email address or last and first names on forms in a GUI application.

There are a few critical points to note regarding widgets in Qt:

  • Information is passed to widgets by way of events. For a textbox, an example of an event could be when a user clicks within the textbox or when the return key has been pressed while a textbox cursor is blinking.
  • Every widget can have a parent widget or children widgets.
  • Widgets that do not have a parent widget become a window when the show() function is called on them. Such a widget will be enclosed in a window with buttons to close, maximize, and minimize it.
  • A child widget is displayed within its parent widget.

Qt organizes its classes with heavy use of inheritance...