Widget Categories
Qt widgets can be categorized in a number of ways to make it easier to find classes you are likely to use. The more complex widgets may cross over into more than one category. This section provides a brief overview of some of the classes we are likely to use as we get started with GUI programming.
There are four categories of widgets. Button widgets, in "Windows style," are shown in Figure 11.2.
Figure 11.2. Button widgets, in "Windows style"
Input widgets, in "Plastique style," are shown in Figure 11.3.
Figure 11.3. Input widgets, in "Plastique style"
Display widgets are non-interactive widgets, such as QLabel, QProgressBar, and QPixMap.
Container widgets, such as the QMainWindow, QFrame, QToolBar, QTabWidget, and QStackedWidget, contain other widgets.
These widgets are used as building blocks to create other more complex widgets, such as:
- Dialogs for asking the user questions or popping up information, such as the QFileDialog, QInputDialog, and QErrorMessage.
- Views that provide displays of collections of data such as QListView, QTReeView, and QTableView.
In addition, there are some Qt classes that do not have any graphical representation (so they are not widgets) but are used in GUI development. They include
- Qt Data types QPoint and QSize are popular types to use when working with graphical objects.
- Controller classes QApplication and QAction are both objects that manage the GUI application's control flow.
- Layouts These are objects that dynamically manage the layout of widgets. There are specific layout varieties: QHBoxLayout, QVBoxLayout, QGridLayout, etc.
- Models The QAbstractItemModel and its derived classes QAbstractListModel and QAbstractTableModel are part of Qt's model/view framework, and are used as base classes for classes that represent data for a QListView, QTReeView, or QTableView.
- Database models These are for use with QTableView (or other customized view classes) using SQL Databases as data sources: QSqlTableModel and QSqlRelationalModel.
To see more widgets rendered in different styles, check out TrollTech's Qt Widget Gallery1, which contains a variety of screenshots and source code for rendering the widgets in different styles.[1]
[1] http://oop.mcs.suffolk.edu/qtdocs/gallery.html