Widgets at a glance

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:

Widget

Description

QCheckBox

This is a checkbox with a text label

QComboBox

This is a combined button and pop-up list

QCommandLinkButton

This is a Vista-style command-link button

QDateEdit

This is a widget that is used to edit dates that are based on the QDateTimeEdit widget

QDateTimeEdit

This is a widget that is used to edit dates and times

QDial

This is a rounded range control (such as a speedometer or potentiometer)

QDoubleSpinBox

This is a spin box widget that takes doubles

QFocusFrame

This is a focus frame, which can be outside of a widget's normal paintable area

QFontComboBox

This is a combobox that lets the user select a font family

QLCDNumber

This displays a number with LCD-like digits

QLabel

This is text or image display

QLineEdit

This is a one-line text editor

QMenu

This is the menu widget for use in menu bars, context menus, and other popup menus

QProgressBar

This is a horizontal or vertical progress bar

QPushButton

This is a command button

QRadioButton

This is a radio button with a text label

QScrollArea

This allows scrolling view onto another widget

QScrollBar

This is a vertical or horizontal scroll bar

QSizeGrip

This is a resize handle to resize top-level windows

QSlider

This is a vertical or horizontal slider

QSpinBox

This is a spin box widget

QTabBar

This is a tab bar, for example, for use in tabbed dialogs

QTabWidget

This is a stack of tabbed widgets

QTimeEdit

This is a widget that is used to edit times that are based on the QDateTimeEdit widget

QToolBox

This is a column of tabbed widget items

QToolButton

This is a quick-access button to commands or options that are usually used inside a QToolBar

QWidget

This is the base class of all user interface objects

The following is a list of predefined advanced widgets:

Widget

Description

QCalendarWidget

This is a monthly-based calendar widget allowing the user to select a date

QColumnView

This is a model/view implementation of a column view

QDataWidgetMapper

This is a mapping between a section of a data model to widgets

QDesktopWidget

This allows access to screen information on multihead systems

QListView

This allows list or icon view onto a model

QMacCocoaViewContainer

This is a widget for Mac OS X that can be used to wrap arbitrary Cocoa views (that is, NSView subclasses) and insert them into Qt hierarchies

QMacNativeWidget

This is a widget for Mac OS X that provides a way to put Qt widgets into Carbon or Cocoa hierarchies depending on how Qt was configured

QTableView

This is the default model/view implementation of a table view

QTreeView

This is the default model/view implementation of a tree view

QUndoView

This displays the contents of a QUndoStack

QWSEmbedWidget

This enables embedded top-level widgets in Qt for Embedded Linux

QWebView

This is a widget that is used to view and edit web documents

QX11EmbedContainer

This is the XEmbed container widget

QX11EmbedWidget

This is the XEmbed client widget

Phonon::VideoWidget

This is a widget that is used to display video

The following is a list of predefined organizer widgets:

Widget

Description

QButtonGroup

This is a container that is used to organize groups of button widgets

QGroupBox

This is a group box frame with a title

QSplitter

This implements a splitter widget

QSplitterHandle

This will handle functionality of the splitter

QStackedWidget

This is a stack of widgets where only one widget is visible at a time

QTabWidget

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.

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

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