Widgets at a glance

Widgets are the basic building blocks of a Graphical User Interface application, which are combined or grouped in a way that helps in interaction and manipulation. 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 list.

Basic widgets

The basic widgets section contains the list of widgets that are simple and designed for direct use. The following list contains the available basic widgets, most of which we have used in the examples that we have seen so far:

Widget

Description

QCheckBox

Provides an option button that can be switched on or off. Associated with a text label.

QComboBox

Provides a pop-up list and a combined button by optimizing the space used for providing a list of options.

QCommandLinkButton

Provides a Vista style command link button similar to that of a radio button used to choose between a set of mutually exclusive options.

QDateEdit

Provides a widget for editing dates. It is inherited from QDateTi me.

QDateTimeEdit

Provides a widget for editing dates and times by using the keyboard.

QDial

Provides a rounded range control widget similar to the ones used in speedometer or potentiometer. Several notches differentiate the main and sub values.

QDoubleSpinBox

Provides a spin box widget that takes doubles. Allows to choose a value by clicking up and down buttons or arrow keys

QFocusFrame

Provides a focus frame which can be outside of a widget's normal paintable area.

QFontComboBox

Provides a combo box widget whose contents are different font family styles in a alphabetized list.

QLCDNumber

Provides a widget that displays the number in LCD like form.

QLabel

Provides an image or text display whose visual appearance can be configured in various ways. It supports plain text, rich text, pixmap, movie, or a number.

QLineEdit

Provides a one-line text editor used to edit a single line of text.

QMenu

Provides a menu widget(selection menu) for use in menu bars, context menus, and other pop-up menus.

QProgressBar

Provides a progress bar widget that helps to indicate the users with the completion status of an activity

QPushButton

Provides a button that is usually executes a command on push or click.

QRadioButton

Provides a radio button option that can be switched on or off associated with a text label.

QScrollArea

Provides a scrolling view that is used to display the contents of a child widget within a frame and also provides scroll bars if the widget exceeds the size of the frame.

QScrollBar

Provides a vertical or a horizontal scroll bar that enables the user to access parts of a document that is larger than the widget used to display it.

QSizeGrip

Provides a standard windows resize handle for resizing top-level windows.

QSlider

Provides a vertical or horizontal slider used for controlling a bounded value. It lets the user move a slider along a horizontal or vertical groove.

QSpinBox

Provides a spin box widget designed to handle integers and discrete set of values.

QTabBar

Provides a tab bar to be used in tabbed dialogs.

QTabWidget

Provides a tab bar and a page area that is used to display pages related to each tab in a stack of tabbed widgets.

QTimeEdit

Provides a widget for editing times inherited by the QDateTimeEdit widget.

QToolBox

Provides a widget that displays a column of tabs one above the other with the current item displayed below the current tab.

QToolButton

Provides a special quick-access button to specific commands or options associated with an icon.

Advanced widgets

Advanced widgets provide more complex user interface controls, which may be used in creating various advanced applications. These widgets make the work of programmers easy by providing us with the most common application features as widget libraries.

Widget

Description

QCalendarWidget

Provides a monthly based calendar widget for date selection initialized with the current month and year.

QColumnView

Provides a widget for model/view implementation of a column view, also referred as cascading list.

QDataWidgetMapper

Provides a widget for mapping between a section of a data model to widgets which is used to create data-aware widgets.

QDesktopWidget

Provides a widget for accessing screen information on multi-head systems; used for managing the physical screen space in user's desktop.

QListView

Provides a widget to present items stored in a model, either as a simple non-hierarchical list or a collection of items.

QTableView

Provides a widget to implement a table view that displays items from a model that represents standard tables.

QTreeView

Provides a widget to implement a tree representation of items from a model that provides standard hierarchical lists.

QUndoView

Provides a widget which displays the list of commands pushed on to a undo stack that has the most recently executed commands in order.

QWebView

Provides a widget that is used to view and edit web documents.

Organizer widgets

The following widgets are mainly used for organizing and grouping various basic and primitive widgets into more complex applications and dialogs:

Widget

Description

QButtonGroup

Provides an abstract container into which button widgets can be placed.

QGroupBox

Provides a group box frame with a title that acts as a place holder for various other widgets.

QSplitter

Provides implementation for a splitter that lets the user control the size of child widgets by dragging the boundary between the child widgets.

QSplitterHandle

Provides a handle functionality for the splitter to resize the windows.

QStackedWidget

Provides a stack of widgets where only one widget is available at a time similar to a tab widget.

QTabWidget

Provides a stack of tabbed widgets.

We have seen the implementation of few of the built-in widgets given in the preceding table in our previous chapters. One of the greatest strengths of PySide lies in the ease of creation of customized widgets. We can group together some of the basic widgets to create a customized widget on our own. Before we could do that, 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 stylesheets 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 those cases, we can subclass QWidget directly and can completely define the behavior and appearance of the widget ourselves. In the example that follows this text, we create a customized "Analog Clock" widget and demonstrate how to create custom widgets.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.217.187