diff options
Diffstat (limited to 'examples/widgets/doc/styles.qdoc')
-rw-r--r-- | examples/widgets/doc/styles.qdoc | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/examples/widgets/doc/styles.qdoc b/examples/widgets/doc/styles.qdoc index f8be98d2da..6dbe3304af 100644 --- a/examples/widgets/doc/styles.qdoc +++ b/examples/widgets/doc/styles.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example widgets/styles + \example widgets/widgets/styles \title Styles Example The Styles example illustrates how to create custom widget @@ -67,7 +67,7 @@ Here's the definition of the \c NorwegianWoodStyle class: - \snippet widgets/styles/norwegianwoodstyle.h 0 + \snippet widgets/widgets/styles/norwegianwoodstyle.h 0 The public functions are all declared in QStyle (QMotifStyle's grandparent class) and reimplemented here to override the Motif @@ -78,7 +78,7 @@ We will now review the implementation of the \c NorwegianWoodStyle class. - \snippet widgets/styles/norwegianwoodstyle.cpp 0 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 0 The \c polish() function is reimplemented from QStyle. It takes a QPalette as a reference and adapts the palette to fit the style. @@ -114,7 +114,7 @@ buttonImage. This image will be used for filling buttons that the user is holding down. - \snippet widgets/styles/norwegianwoodstyle.cpp 1 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 1 We initialize the palette. Palettes have various \l{QPalette::ColorRole}{color roles}, such as QPalette::Base @@ -156,8 +156,8 @@ Let's move on to the other functions reimplemented from QMotifStyle: - \snippet widgets/styles/norwegianwoodstyle.cpp 3 - \snippet widgets/styles/norwegianwoodstyle.cpp 4 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 3 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 4 This QStyle::polish() overload is called once on every widget drawn using the style. We reimplement it to set the Qt::WA_Hover @@ -167,8 +167,8 @@ render push buttons and comboboxes differently when the mouse pointer is over them. - \snippet widgets/styles/norwegianwoodstyle.cpp 5 - \snippet widgets/styles/norwegianwoodstyle.cpp 6 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 5 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 6 This QStyle::unpolish() overload is called to undo any modification done to the widget in \c polish(). For simplicity, @@ -177,8 +177,8 @@ widgets (e.g., using a QMap<QWidget *, bool>) and restore it in \c unpolish(). - \snippet widgets/styles/norwegianwoodstyle.cpp 7 - \snippet widgets/styles/norwegianwoodstyle.cpp 8 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 7 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 8 The \l{QStyle::pixelMetric()}{pixelMetric()} function returns the size in pixels for a certain user interface element. By @@ -197,8 +197,8 @@ For all other QStyle::PixelMetric elements, we use the Motif settings. - \snippet widgets/styles/norwegianwoodstyle.cpp 9 - \snippet widgets/styles/norwegianwoodstyle.cpp 10 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 9 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 10 The \l{QStyle::styleHint()}{styleHint()} function returns some hints to widgets or to the base style (in our case QMotifStyle) @@ -209,8 +209,8 @@ QStyle::SH_EtchDisabledText hint, meaning that disabled text is rendered with an embossed look (as QWindowsStyle does). - \snippet widgets/styles/norwegianwoodstyle.cpp 11 - \snippet widgets/styles/norwegianwoodstyle.cpp 12 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 11 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 12 The \l{QStyle::drawPrimitive()}{drawPrimitive()} function is called by Qt widgets to draw various fundamental graphical @@ -241,8 +241,8 @@ QStyle::State_MouseOver flag to be set when the mouse is over the widget. - \snippet widgets/styles/norwegianwoodstyle.cpp 13 - \snippet widgets/styles/norwegianwoodstyle.cpp 14 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 13 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 14 The \c roundRect variable is a QPainterPath. A QPainterPath is is a vectorial specification of a shape. Any shape (rectangle, @@ -252,10 +252,10 @@ \c roundRectPath() function is a private function; we will come back to it later. - \snippet widgets/styles/norwegianwoodstyle.cpp 15 - \snippet widgets/styles/norwegianwoodstyle.cpp 16 - \snippet widgets/styles/norwegianwoodstyle.cpp 17 - \snippet widgets/styles/norwegianwoodstyle.cpp 18 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 15 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 16 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 17 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 18 We define two variables, \c brush and \c darker, and initialize them based on the state of the button: @@ -287,11 +287,11 @@ performs a dynamic cast; if \c option is not a QStyleOptionButton, qstyleoption_cast() returns a null pointer. - \snippet widgets/styles/norwegianwoodstyle.cpp 19 - \snippet widgets/styles/norwegianwoodstyle.cpp 20 - \snippet widgets/styles/norwegianwoodstyle.cpp 21 - \snippet widgets/styles/norwegianwoodstyle.cpp 22 - \snippet widgets/styles/norwegianwoodstyle.cpp 23 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 19 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 20 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 21 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 22 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 23 We turn on antialiasing on QPainter. Antialiasing is a technique that reduces the visual distortion that occurs when the edges of @@ -306,8 +306,8 @@ semi-transparent black color (a black color with an alpha channel of 63) to make the area darker if \c darker is true. - \snippet widgets/styles/norwegianwoodstyle.cpp 24 - \snippet widgets/styles/norwegianwoodstyle.cpp 25 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 24 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 25 Next, we draw the outline. The top-left half of the outline and the bottom-right half of the outline are drawn using different @@ -318,7 +318,7 @@ \l{QAbstractButton::checked}{checked}, we invert the two \l{QPen}s to give a sunken look to the button. - \snippet widgets/styles/norwegianwoodstyle.cpp 26 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 26 We draw the top-left part of the outline by calling QPainter::drawPath() with an appropriate @@ -340,9 +340,9 @@ pass the \c -reverse command-line option to the application. This option is recognized by the QApplication constructor. - \snippet widgets/styles/norwegianwoodstyle.cpp 32 - \snippet widgets/styles/norwegianwoodstyle.cpp 33 - \snippet widgets/styles/norwegianwoodstyle.cpp 34 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 32 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 33 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 34 The bottom-right part of the outline is drawn in a similar fashion. Then we draw a one-pixel wide outline around the entire @@ -354,8 +354,8 @@ base style. Let's now turn to the other \c NorwegianWoodStyle member functions: - \snippet widgets/styles/norwegianwoodstyle.cpp 35 - \snippet widgets/styles/norwegianwoodstyle.cpp 36 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 35 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 36 We reimplement QStyle::drawControl() to draw the text on a QPushButton in a bright color when the button is @@ -368,8 +368,8 @@ QPalette::ButtonText be the same as the QPalette::BrightText component (unless the widget is disabled). - \snippet widgets/styles/norwegianwoodstyle.cpp 37 - \snippet widgets/styles/norwegianwoodstyle.cpp 38 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 37 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 38 The \c setTexture() function is a private function that sets the \l{QBrush::texture()}{texture} component of the \l{QBrush}es for @@ -378,8 +378,8 @@ inactive). We used it to initialize the Norwegian Wood palette in \c polish(QPalette &). - \snippet widgets/styles/norwegianwoodstyle.cpp 39 - \snippet widgets/styles/norwegianwoodstyle.cpp 40 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 39 + \snippet widgets/widgets/styles/norwegianwoodstyle.cpp 40 The \c roundRectPath() function is a private function that constructs a QPainterPath object for round buttons. The path @@ -397,13 +397,13 @@ class, which contains the most common Qt widgets and allows the user to change style dynamically. Here's the class definition: - \snippet widgets/styles/widgetgallery.h 0 + \snippet widgets/widgets/styles/widgetgallery.h 0 \dots - \snippet widgets/styles/widgetgallery.h 1 + \snippet widgets/widgets/styles/widgetgallery.h 1 Here's the \c WidgetGallery constructor: - \snippet widgets/styles/widgetgallery.cpp 0 + \snippet widgets/widgets/styles/widgetgallery.cpp 0 We start by creating child widgets. The \uicontrol Style combobox is initialized with all the styles known to QStyleFactory, in @@ -411,8 +411,8 @@ private functions that set up the various parts of the \c WidgetGallery. - \snippet widgets/styles/widgetgallery.cpp 1 - \snippet widgets/styles/widgetgallery.cpp 2 + \snippet widgets/widgets/styles/widgetgallery.cpp 1 + \snippet widgets/widgets/styles/widgetgallery.cpp 2 We connect the \uicontrol Style combobox to the \c changeStyle() private slot, the \uicontrol{Use style's standard palette} check box to @@ -420,20 +420,20 @@ box to the child widgets' \l{QWidget::setDisabled()}{setDisabled()} slot. - \snippet widgets/styles/widgetgallery.cpp 3 - \snippet widgets/styles/widgetgallery.cpp 4 + \snippet widgets/widgets/styles/widgetgallery.cpp 3 + \snippet widgets/widgets/styles/widgetgallery.cpp 4 Finally, we put the child widgets in layouts. - \snippet widgets/styles/widgetgallery.cpp 5 - \snippet widgets/styles/widgetgallery.cpp 6 + \snippet widgets/widgets/styles/widgetgallery.cpp 5 + \snippet widgets/widgets/styles/widgetgallery.cpp 6 When the user changes the style in the combobox, we call QApplication::setStyle() to dynamically change the style of the application. - \snippet widgets/styles/widgetgallery.cpp 7 - \snippet widgets/styles/widgetgallery.cpp 8 + \snippet widgets/widgets/styles/widgetgallery.cpp 7 + \snippet widgets/widgets/styles/widgetgallery.cpp 8 If the user turns the \uicontrol{Use style's standard palette} on, the current style's \l{QStyle::standardPalette()}{standard palette} @@ -443,8 +443,8 @@ always override the palette with our own palette in \c NorwegianWoodStyle::polish(). - \snippet widgets/styles/widgetgallery.cpp 9 - \snippet widgets/styles/widgetgallery.cpp 10 + \snippet widgets/widgets/styles/widgetgallery.cpp 9 + \snippet widgets/widgets/styles/widgetgallery.cpp 10 The \c advanceProgressBar() slot is called at regular intervals to advance the progress bar. Since we don't know how long the @@ -454,8 +454,8 @@ We will review \c createProgressBar() in a moment. - \snippet widgets/styles/widgetgallery.cpp 11 - \snippet widgets/styles/widgetgallery.cpp 12 + \snippet widgets/widgets/styles/widgetgallery.cpp 11 + \snippet widgets/widgets/styles/widgetgallery.cpp 12 The \c createTopLeftGroupBox() function creates the QGroupBox that occupies the top-left corner of the \c WidgetGallery. We @@ -463,7 +463,7 @@ createBottomLeftTabWidget(), and \c createBottomRightGroupBox() functions, which are very similar. - \snippet widgets/styles/widgetgallery.cpp 13 + \snippet widgets/widgets/styles/widgetgallery.cpp 13 In \c createProgressBar(), we create a QProgressBar at the bottom of the \c WidgetGallery and connect its |