| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:FDL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in a
|
|---|
| 14 | ** written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Free Documentation License
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
|---|
| 18 | ** Documentation License version 1.3 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file included in the packaging of this
|
|---|
| 20 | ** file.
|
|---|
| 21 | **
|
|---|
| 22 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 23 | ** Nokia at qt-info@nokia.com.
|
|---|
| 24 | ** $QT_END_LICENSE$
|
|---|
| 25 | **
|
|---|
| 26 | ****************************************************************************/
|
|---|
| 27 |
|
|---|
| 28 | /*!
|
|---|
| 29 | \page widgets-and-layouts.html
|
|---|
| 30 | \title Widgets and Layouts
|
|---|
| 31 | \ingroup qt-gui-concepts
|
|---|
| 32 | \brief The primary elements for designing user interfaces in Qt.
|
|---|
| 33 |
|
|---|
| 34 | \section1 Widgets
|
|---|
| 35 |
|
|---|
| 36 | Widgets are the primary elements for creating user interfaces in Qt.
|
|---|
| 37 | \l{The Widget Classes}{Widgets} can display data and status information,
|
|---|
| 38 | receive user input, and provide a container for other widgets that
|
|---|
| 39 | should be grouped together. A widget that is not embedded in a
|
|---|
| 40 | parent widget is called a \l{Window and Dialog Widgets} {window}.
|
|---|
| 41 |
|
|---|
| 42 | \image parent-child-widgets.png A parent widget containing various child widgets.
|
|---|
| 43 |
|
|---|
| 44 | The QWidget class provides the basic capability to render to the
|
|---|
| 45 | screen, and to handle user input events. All UI elements that Qt
|
|---|
| 46 | provides are either subclasses of QWidget, or are used in connection
|
|---|
| 47 | with a QWidget subclass. Creating custom widgets is done by
|
|---|
| 48 | subclassing QWidget or a suitable subclass and reimplementing the
|
|---|
| 49 | virtual event handlers.
|
|---|
| 50 |
|
|---|
| 51 | \section1 Layouts
|
|---|
| 52 |
|
|---|
| 53 | \l{Layout Management}{Layouts} are an elegant and flexible way to
|
|---|
| 54 | automatically arrange child widgets within their container. Each
|
|---|
| 55 | widget reports its size requirements to the layout through the
|
|---|
| 56 | \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} properties,
|
|---|
| 57 | and the layout distributes the available space accordingly.
|
|---|
| 58 |
|
|---|
| 59 | \table
|
|---|
| 60 | \row
|
|---|
| 61 | \o \image qgridlayout-with-5-children.png
|
|---|
| 62 | \o \image qformlayout-with-6-children.png
|
|---|
| 63 | \endtable
|
|---|
| 64 |
|
|---|
| 65 | \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and
|
|---|
| 66 | arranging widgets in layouts.
|
|---|
| 67 |
|
|---|
| 68 | \section1 Widget Styles
|
|---|
| 69 |
|
|---|
| 70 | \l{Styles and Style Aware Widgets}{Styles} draw on behalf of
|
|---|
| 71 | widgets and encapsulate the look and feel of a GUI. Qt's built-in
|
|---|
| 72 | widgets use the QStyle class to perform nearly all of their drawing,
|
|---|
| 73 | ensuring that they look exactly like the equivalent native widgets.
|
|---|
| 74 |
|
|---|
| 75 | \table
|
|---|
| 76 | \row
|
|---|
| 77 | \o \image windowsxp-tabwidget.png
|
|---|
| 78 | \o \image plastique-tabwidget.png
|
|---|
| 79 | \o \image macintosh-tabwidget.png
|
|---|
| 80 | \endtable
|
|---|
| 81 |
|
|---|
| 82 | \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the
|
|---|
| 83 | appearance of widgets, in addition to what is already possible by subclassing QStyle.
|
|---|
| 84 |
|
|---|
| 85 | \section1 The Widget Classes
|
|---|
| 86 |
|
|---|
| 87 | The following sections list the widget classes. See the \l{Qt Widget
|
|---|
| 88 | Gallery} for some examples.
|
|---|
| 89 |
|
|---|
| 90 | \section2 Basic Widgets
|
|---|
| 91 |
|
|---|
| 92 | These basic widgets (controls), e.g. buttons, comboboxes and
|
|---|
| 93 | scroll bars, are designed for direct use.
|
|---|
| 94 |
|
|---|
| 95 | \table
|
|---|
| 96 | \row
|
|---|
| 97 | \o \image windows-label.png
|
|---|
| 98 | \o \image windowsvista-pushbutton.png
|
|---|
| 99 | \o \image gtk-progressbar.png
|
|---|
| 100 | \row
|
|---|
| 101 | \o \image plastique-combobox.png
|
|---|
| 102 | \o \image macintosh-radiobutton.png
|
|---|
| 103 | \o \image cde-lineedit.png
|
|---|
| 104 | \endtable
|
|---|
| 105 |
|
|---|
| 106 | \annotatedlist basicwidgets
|
|---|
| 107 |
|
|---|
| 108 | \section2 Advanced Widgets
|
|---|
| 109 |
|
|---|
| 110 | Advanced GUI widgets, e.g. tab widgets and progress bars, provide
|
|---|
| 111 | more complex user interface controls.
|
|---|
| 112 |
|
|---|
| 113 | \table
|
|---|
| 114 | \row
|
|---|
| 115 | \o \image windowsxp-treeview.png
|
|---|
| 116 | \o \image gtk-calendarwidget.png
|
|---|
| 117 | \o \image qundoview.png
|
|---|
| 118 | \endtable
|
|---|
| 119 |
|
|---|
| 120 | \annotatedlist advanced
|
|---|
| 121 |
|
|---|
| 122 | \table
|
|---|
| 123 | \row
|
|---|
| 124 | \o \image windowsvista-tabwidget.png
|
|---|
| 125 | \o \image macintosh-groupbox.png
|
|---|
| 126 | \endtable
|
|---|
| 127 |
|
|---|
| 128 | \section2 Organizer Widgets
|
|---|
| 129 |
|
|---|
| 130 | Classes like splitters, tab bars, button groups, etc are used for
|
|---|
| 131 | organizing and grouping GUI primitives into more complex
|
|---|
| 132 | applications and dialogs.
|
|---|
| 133 |
|
|---|
| 134 | \annotatedlist organizers
|
|---|
| 135 |
|
|---|
| 136 | \section2 Abstract Widget Classes
|
|---|
| 137 |
|
|---|
| 138 | The abstract widget classes are base classes. They are not usable as
|
|---|
| 139 | standalone classes but provide functionality when they are subclassed.
|
|---|
| 140 |
|
|---|
| 141 | \annotatedlist abstractwidgets
|
|---|
| 142 | */
|
|---|
| 143 |
|
|---|
| 144 | /*!
|
|---|
| 145 | \group advanced
|
|---|
| 146 | \title Advanced Widgets
|
|---|
| 147 | */
|
|---|
| 148 |
|
|---|
| 149 | /*!
|
|---|
| 150 | \group abstractwidgets
|
|---|
| 151 | \title Abstract Widget Classes
|
|---|
| 152 | */
|
|---|
| 153 |
|
|---|
| 154 | /*!
|
|---|
| 155 | \group basicwidgets
|
|---|
| 156 | \title Basic Widgets
|
|---|
| 157 | */
|
|---|
| 158 |
|
|---|
| 159 | /*!
|
|---|
| 160 | \group organizers
|
|---|
| 161 | \title Organizers
|
|---|
| 162 | */
|
|---|