Widgets are the basic building blocks of a Graphical User Interface hierarchy in GUI applications. Widgets are basically used to display data and status information, receive user input, and provide a container for other widgets that should be grouped together. Qt comes with a variety of basic and advanced built-in widgets that can be customized to our own needs. A list of predefined widgets is given in the following tables for your reference. QWidget
is the base class for all the widgets given in the following lists.
The following is a list of predefined basic widgets:
The following is a list of predefined advanced widgets:
The following is a list of predefined organizer widgets:
Widget |
Description |
---|---|
|
This is a container that is used to organize groups of button widgets |
|
This is a group box frame with a title |
|
This implements a splitter widget |
|
This will handle functionality of the splitter |
|
This is a stack of widgets where only one widget is visible at a time |
|
This is a stack of tabbed widgets |
We saw the implementation of a few of these built-in widgets in our previous chapters. One of the greatest strengths of PySide lies in the ease of creation of customized widgets. We can group some of the basic widgets together to create a customized widget on our own. Before we can do this, we also have several ways to customize a widget to suit our needs. The basic form of customization is to change the properties of the existing widget. We can also opt to use style sheets to customize the widget's appearance and some aspects of its behavior. In some cases, it is highly likely that we may require a widget that is different from any of the standard widgets. In these cases, we can subclass QWidget directly and can completely define the behavior and appearance of the widget ourselves. In the next example, we create a customized Analog Clock widget and demonstrate how to create custom widgets.