source: trunk/doc/src/widgets-and-layouts/styles.qdoc@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 81.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
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
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \group appearance
44 \title Widget Appearance and Style
45 \brief Classes used for customizing UI appearance and style.
46*/
47
48/*!
49 \page style-reference.html
50 \title Implementing Styles and Style Aware Widgets
51 \brief An overview of styles and the styling of widgets.
52
53 \ingroup frameworks-technologies
54
55 \previouspage Widget Classes
56 \contentspage Widgets and Layouts
57 \nextpage {Qt Style Sheets}{Style sheets}
58
59 Styles (classes that inherit QStyle) draw on behalf of widgets
60 and encapsulate the look and feel of a GUI. The QStyle class is
61 an abstract base class that encapsulates the look and feel of a
62 GUI. Qt's built-in widgets use it to perform nearly all of their
63 drawing, ensuring that they look exactly like the equivalent
64 native widgets.
65
66 Several styles are built into Qt (e.g., windows style and motif style).
67 Other styles are only available on specific platforms (such as
68 the windows XP style). Custom styles are made available as plugins
69 or by creating an instance of the style class in an application and
70 setting it with QApplication::setStyle().
71
72 To implement a new style, you inherit one of Qt's existing styles
73 - the one most resembling the style you want to create - and
74 reimplement a few virtual functions. This process is somewhat
75 involved, and we therefore provide this overview. We give a
76 step-by-step walkthrough of how to style individual Qt widgets.
77 We will examine the QStyle virtual functions, member variables,
78 and enumerations.
79
80 The part of this document that does not concern the styling of
81 individual widgets is meant to be read sequentially because later
82 sections tend to depend on earlier ones. The description of the
83 widgets can be used for reference while implementing a style.
84 However, you may need to consult the Qt source code in some cases.
85 The sequence in the styling process should become clear after
86 reading this document, which will aid you in locating relevant code.
87
88 To develop style aware widgets (i.e., widgets that conform to
89 the style in which they are drawn), you need to draw them using the
90 current style. This document shows how widgets draw themselves
91 and which possibilities the style gives them.
92
93 \tableofcontents
94
95 \section1 Classes for Widget Styling
96
97 These classes are used to customize an application's appearance and
98 style.
99
100 \annotatedlist appearance
101
102 \section1 The QStyle implementation
103
104 The API of QStyle contains functions that draw the widgets, static
105 helper functions to do common and difficult tasks (e.g.,
106 calculating the position of slider handles) and functions to do
107 the various calculations necessary while drawing (e.g., for the
108 widgets to calculate their size hints). The style also help some
109 widgets with the layout of their contents. In addition, it creates
110 a QPalette that contains \l{QBrush}es to draw with.
111
112 QStyle draws graphical elements; an element is a widget or a
113 widget part like a push button bevel, a window frame, or a scroll
114 bar. Most draw functions now take four arguments:
115
116 \list
117 \o an enum value specifying which graphical element to draw
118 \o a QStyleOption specifying how and where to render that element
119 \o a QPainter that should be used to draw the element
120 \o a QWidget on which the drawing is performed (optional)
121 \endlist
122
123 When a widget asks a style to draw an element, it provides the style
124 with a QStyleOption, which is a class that contains the information
125 necessary for drawing. Thanks to QStyleOption, it is possible to make
126 QStyle draw widgets without linking in any code for the widget. This
127 makes it possible to use \l{QStyle}'s draw functions on any paint
128 device, i.e., you can draw a combobox on any widget, not just on a
129 QComboBox.
130
131 The widget is passed as the last argument in case the style needs
132 it to perform special effects (such as animated default buttons on
133 Mac OS X), but it isn't mandatory.
134
135 We will in the course of this section look at the style elements,
136 the style options, and the functions of QStyle. Finally, we describe
137 how the palette is used.
138
139 Items in item views is drawn by \l{Delegate Classes}{delegates} in
140 Qt. The item view headers are still drawn by the style. Qt's
141 default delegate, QStyledItemDelegate, draws its items partially
142 through the current style; it draws the check box indicators and
143 calculate bounding rectangles for the elements of which the item
144 consists. In this document, we only describe how to implement a
145 QStyle subclass. If you wish to add support for other datatypes
146 than those supported by the QStyledItemDelegate, you need to
147 implement a custom delegate. Note that delegates must be set
148 programmatically for each individual widget (i.e., default
149 delegates cannot be provided as plugins).
150
151 \section2 The Style Elements
152
153 A style element is a graphical part of a GUI. A widget consists
154 of a hierarchy (or tree) of style elements. For instance, when a
155 style receives a request to draw a push button (from QPushButton,
156 for example), it draws a label (text and icon), a button bevel,
157 and a focus frame. The button bevel, in turn, consists of a frame
158 around the bevel and two other elements, which we will look at
159 later. Below is a conceptual illustration of the push button
160 element tree. We will see the actual tree for QPushButton when we
161 go through the individual widgets.
162
163 \image javastyle/conceptualpushbuttontree.png
164
165 Widgets are not necessarily drawn by asking the style to draw
166 only one element. Widgets can make several calls to the style to
167 draw different elements. An example is QTabWidget, which draws its
168 tabs and frame individually.
169
170 There are three element types: primitive elements, control
171 elements, and complex control elements. The elements are defined
172 by the \l{QStyle::}{ComplexControl}, \l{QStyle::}{ControlElement},
173 and \l{QStyle::}{PrimitiveElement} enums. The values of
174 each element enum has a prefix to identify their type: \c{CC_} for
175 complex elements, \c{CE_} for control elements, and \c{PE_} for
176 primitive elements. We will in the following three sections see what
177 defines the different elements and see examples of widgets that use
178 them.
179
180 The QStyle class description contains a list of these elements and
181 their roles in styling widgets. We will see how they are used when
182 we style individual widgets.
183
184 \section3 Primitive Elements
185
186 Primitive elements are GUI elements that are common and often used
187 by several widgets. Examples of these are frames, button bevels,
188 and arrows for spin boxes, scroll bars, and combo boxes.
189 Primitive elements cannot exist on their own: they are always part
190 of a larger construct. They take no part in the interaction with
191 the user, but are passive decorations in the GUI.
192
193 \section3 Control Elements
194
195 A control element performs an action or displays information
196 to the user. Examples of control elements are push buttons, check
197 boxes, and header sections in tables and tree views. Control
198 elements are not necessarily complete widgets such as push
199 buttons, but can also be widget parts such as tab bar tabs and
200 scroll bar sliders. They differ from primitive elements in that
201 they are not passive, but fill a function in the interaction with
202 the user. Controls that consist of several elements often use the
203 style to calculate the bounding rectangles of the elements. The
204 available sub elements are defined by the \l{QStyle::}{SubElement}
205 enum. This enum is only used for calculating bounding rectangles,
206 and sub elements are as such not graphical elements to be drawn
207 like primitive, control, and complex elements.
208
209 \section3 Complex Control Elements
210
211 Complex control elements contain sub controls. Complex controls
212 behave differently depending on where the user handles them with
213 the mouse and which keyboard keys are pressed. This is dependent
214 on which sub control (if any) that the mouse is over or received a
215 mouse press. Examples of complex controls are scroll bars and
216 combo boxes. With a scroll bar, you can use the mouse to move the
217 slider and press the line up and line down buttons. The available
218 sub controls are defined by the \l{QStyle}{SubControl} enum.
219
220 In addition to drawing, the style needs to provide the widgets
221 with information on which sub control (if any) a mouse press was
222 made on. For instance, a QScrollBar needs to know if the user
223 pressed the slider, the slider groove, or one of the buttons.
224
225 Note that sub controls are not the same as the control elements
226 described in the previous section. You cannot use the style to
227 draw a sub control; the style will only calculate the bounding
228 rectangle in which the sub control should be drawn. It is common,
229 though, that complex elements use control and primitive elements
230 to draw their sub controls, which is an approach that is
231 frequently used by the built-in styles in Qt and also the Java
232 style. For instance, the Java style uses PE_IndicatorCheckBox to
233 draw the check box in group boxes (which is a sub control of
234 CC_GroupBox). Some sub controls have an equivalent control element,
235 e.g., the scroll bar slider (SC_SCrollBarSlider and
236 CE_ScrollBarSlider).
237
238 \section3 Other QStyle Tasks
239
240 The style elements and widgets, as mentioned, use the style to
241 calculate bounding rectangles of sub elements and sub controls,
242 and pixel metrics, which is a style dependent size in screen
243 pixels, for measures when drawing. The available rectangles and
244 pixel metrics are represented by three enums in QStyle:
245 \l{QStyle::}{SubElement}, \l{QStyle::}{SubControl}, and
246 \l{QStyle::}{PixelMetric}. Values of the enums can easily by
247 identified as they start with SE_, SC_ and PM_.
248
249 The style also contain a set of style hints, which is
250 represented as values in the \l{QStyle::}{StyleHint} enum. All
251 widgets do not have the same functionality and look in the
252 different styles. For instance, when the menu items in a menu do not
253 fit in a single column on the screen, some styles support
254 scrolling while others draw more than one column to fit all items.
255
256 A style usually has a set of standard images (such as a warning, a
257 question, and an error image) for message boxes, file dialogs,
258 etc. QStyle provides the \l{QStyle::}{StandardPixmap} enum. Its
259 values represent the standard images. Qt's widgets use these, so
260 when you implement a custom style you should supply the images
261 used by the style that is being implemented.
262
263 The style calculates the spacing between widgets in layouts. There
264 are two ways the style can handle these calculations. You can set
265 the PM_LayoutHorizontalSpacing and PM_LayoutVerticalSpacing, which
266 is the way the java style does it (through QCommonStyle).
267 Alternatively, you can implement QStyle::layoutSpacing() and
268 QStyle::layoutSpacingImplementation() if you need more control over
269 this part of the layout. In these functions you can calculate the
270 spacing based on control types (QSizePolicy::ControlType) for
271 different size policies (QSizePolicy::Policy) and also the style
272 option for the widget in question.
273
274 \section2 Style Options
275
276 The sub-classes of QStyleOption contain all information necessary
277 to style the individual elements. Style options are instantiated -
278 usually on the stack - and filled out by the caller of the QStyle
279 function. Depending on what is drawn the style will expect
280 different a different style option class. For example, the
281 QStyle::PE_FrameFocusRect element expects a QStyleOptionFocusRect
282 argument, and it's possible to create custom subclasses that a
283 custom style can use. The style options keep public variables
284 for performance reasons.
285
286 The widgets can be in a number of different states, which are
287 defined by the \l{QStyle::}{State} enum. Some of the state flags have
288 different meanings depending on the widget, but others are common
289 for all widgets like State_Disabled. It is QStyleOption that sets
290 the common states with QStyleOption::initFrom(); the rest of the
291 states are set by the individual widgets.
292
293 Most notably, the style options contain the palette and bounding
294 rectangles of the widgets to be drawn. Most widgets have
295 specialized style options. QPushButton and QCheckBox, for
296 instance, use QStyleOptionButton as style option, which contain
297 the text, icon, and the size of their icon. The exact contents of
298 all options are described when we go through individual widgets.
299
300 When reimplementing QStyle functions that take a
301 QStyleOption parameter, you often need to cast the
302 QStyleOption to a subclass (e.g., QStyleOptionFocusRect). For
303 safety, you can use qstyleoption_cast() to ensure that the
304 pointer type is correct. If the object isn't of the right type,
305 qstyleoption_cast() returns 0. For example:
306
307 \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 0
308
309 The following code snippet illustrates how to use QStyle to
310 draw the focus rectangle from a custom widget's paintEvent():
311
312 \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 1
313
314 The next example shows how to derive from an existing style to
315 customize the look of a graphical element:
316
317 \snippet doc/src/snippets/customstyle/customstyle.h 0
318 \codeline
319 \snippet doc/src/snippets/customstyle/customstyle.cpp 2
320 \snippet doc/src/snippets/customstyle/customstyle.cpp 3
321 \snippet doc/src/snippets/customstyle/customstyle.cpp 4
322
323 \section2 QStyle Functions
324
325 The QStyle class defines three functions for drawing the primitive,
326 control, and complex elements:
327 \l{QStyle::}{drawPrimitive()},
328 \l{QStyle::}{drawControl()}, and
329 \l{QStyle::}{drawComplexControl()}. The functions takes the
330 following parameters:
331
332 \list
333 \o the enum value of the element to draw
334 \o a QStyleOption which contains the information needed to
335 draw the element.
336 \o a QPainter with which to draw the element.
337 \o a pointer to a QWidget, typically the widget
338 that the element is painted on.
339 \endlist
340
341 Not all widgets send a pointer to themselves. If the style
342 option sent to the function does not contain the information you
343 need, you should check the widget implementation to see if it
344 sends a pointer to itself.
345
346 The QStyle class also provides helper functions that are used
347 when drawing the elements. The \l{QStyle::}{drawItemText()}
348 function draws text within a specified rectangle and taking a
349 QPalette as a parameter. The \l{QStyle::}{drawItemPixmap()}
350 function helps to align a pixmap within a specified bounding
351 rectangle.
352
353 Other QStyle functions do various calculations for the
354 functions that draw. The widgets also use these functions for
355 calculating size hints and also for bounding rectangle
356 calculations if they draw several style elements themselves.
357 As with the functions that draw elements the helper functions
358 typically takes the same arguments.
359
360 \list
361 \o The \l{QStyle::}{subElementRect()} function takes a
362 \l{QStyle::}{SubElement} enum value, and calculates a bounding
363 rectangle for a sub element. The style uses this function to
364 know where to draw the different parts of an element. This is
365 mainly done for reuse. If you create a new style, you can use
366 the same location of sub elements as the super class.
367
368 \o The \l{QStyle::}{subControlRect()} function is used to
369 calculate bounding rectangles for sub controls in complex
370 controls. When you implement a new style, you reimplement \c
371 subControlRect() and calculate the rectangles that are different
372 from the super class.
373
374 \o The \l{QStyle::}{pixelMetric()} function returns a pixel
375 metric, which is a style dependent size given in screen
376 pixels. It takes a value of the \l{QStyle::}{PixelMetric} enum
377 and returns the correct measure. Note that pixel metrics do
378 not necessarily have to be static measures, but can be
379 calculated with, for example, the style option.
380
381 \o The \l{QStyle::}{hitTestComplexControl()} function returns the
382 sub control that the mouse pointer is over in a complex control.
383 Usually, this is simply a matter of using
384 \l{QStyle::}{subControlRect()} to get the bounding rectangles of
385 the sub controls, and see which rectangle contains the position of
386 the cursor.
387 \endlist
388
389 QStyle also have the functions \l{QStyle::}{polish()} and
390 \l{QStyle::}{unpolish()}. All widgets are sent to the \c polish()
391 function before being shown and to \c unpolish() when they
392 are hidden. You can use these functions to set attributes on the
393 widgets or do other work that is required by your style. For
394 instance, if you need to know when the mouse is hovering over the
395 widget, you need to set the \l{Qt::}{WA_Hover} widget attribute.
396 The State_MouseOver state flag will then be set in the widget's
397 style options.
398
399 QStyle has a few static helper functions that do some common and
400 difficult tasks. They can calculate the position of a slider
401 handle from the value of the slider and transform rectangles
402 and draw text considering reverse layouts; see the QStyle
403 class documentation for more details.
404
405 The usual approach when one reimplements QStyle virtual
406 functions is to do work on elements that are different from the
407 super class; for all other elements, you can simply use the super
408 class implementation.
409
410 \section2 The Palette
411
412 Each style provides a color - that is, QBrush - palette that
413 should be used for drawing the widgets. There is one set of colors
414 for the different widget states (QPalette::ColorGroup): active
415 (widgets in the window that has keyboard focus), inactive (widgets
416 used for other windows), and disabled (widgets that are set
417 disabled). The states can be found by querying the State_Active
418 and State_Enabled state flags. Each set contains color certain
419 roles given by the QPalette::ColorRole enum. The roles describe in
420 which situations the colors should be used (e.g., for painting
421 widget backgrounds, text, or buttons).
422
423 How the color roles are used is up to the style. For instance, if
424 the style uses gradients, one can use a palette color and make it
425 darker or lighter with QColor::darker() and QColor::lighter() to
426 create the gradient. In general, if you need a brush that is not
427 provided by the palette, you should try to derive it from one.
428
429 QPalette, which provides the palette, stores colors for
430 different widget states and color roles. The palette for a style
431 is returned by \l{QStyle::}{standardPalette()}. The standard
432 palette is not installed automatically when a new style is set
433 on the application (QApplication::setStyle()) or widget
434 (QWidget::setStyle()), so you must set the palette yourself
435 with (QApplication::setPalette()) or (QWidget::setPalette()).
436
437 It is not recommended to hard code colors as applications and
438 individual widgets can set their own palette and also use the
439 styles palette for drawing. Note that none of Qt's widgets set
440 their own palette. The java style does hard code some colors, but
441 its author looks past this in silence. Of course, it is not
442 intended that the style should look good with any palette.
443
444 \section2 Implementation Issues
445
446 When you implement styles, there are several issues to
447 consider. We will give some hints and advice on implementation
448 here.
449
450 When implementing styles, it is necessary to look through the
451 code of the widgets and code of the base class and its ancestors.
452 This is because the widgets use the style differently, because the
453 implementation in the different styles virtual functions can
454 affect the state of the drawing (e.g., by altering the QPainter
455 state without restoring it and drawing some elements without using
456 the appropriate pixel metrics and sub elements).
457
458 It is recommended that the styles do not alter the proposed size
459 of widgets with the QStyle::sizeFromContents() function but let
460 the QCommonStyle implementation handle it. If changes need to be
461 made, you should try to keep them small; application development
462 may be difficult if the layout of widgets looks considerably
463 different in the various styles.
464
465 We recommend using the QPainter directly for drawing, i.e., not
466 use pixmaps or images. This makes it easier for the style conform
467 to the palette (although you can set your own color table on a
468 QImage with \l{QImage::}{setColorTable()}).
469
470 It is, naturally, possible to draw elements without using the
471 style to draw the sub elements as intended by Qt. This is
472 discouraged as custom widgets may depend on these sub elements to
473 be implemented correctly. The widget walkthrough shows how Qt
474 uses the sub elements.
475
476 \section1 Java Style
477
478 We have implemented a style that resembles the Java default look
479 and feel (previously known as Metal). We have done this as it is
480 relatively simple to implement and we wanted to build a style for
481 this overview document. To keep it simple and not to extensive, we
482 have simplified the style somewhat, but Qt is perfectly able to
483 make an exact copy of the style. However, there are no concrete
484 plans to implement the style as a part of Qt.
485
486 In this section we will have a look at some implementation
487 issues. Finally, we will see a complete example on the styling of
488 a Java widget. We will continue to use the java style
489 throughout the document for examples and widget images. The
490 implementation itself is somewhat involved, and it is not
491 intended that you should read through it.
492
493 \section2 Design and Implementation
494
495 The first step in designing the style was to select the base
496 class. We chose to subclass QWindowsStyle. This class implements
497 most of the functionality we need other than performing the actual
498 drawing. Also, windows and java share layout of sub controls for
499 several of the complex controls (which reduces the amount of code
500 required considerably).
501
502 The style is implemented in one class. We have done this
503 because we find it convenient to keep all code in one file. Also,
504 it is an advantage with regards to optimization as we instantiate
505 less objects. We also keep the number of functions at a minimum by
506 using switches to identify which element to draw in the functions.
507 This results in large functions, but since we divide the code for
508 each element in the switches, the code should still be easy to
509 read.
510
511 \section2 Limitations and Differences from Java
512
513 We have not fully implemented every element in the Java style.
514 This way, we have reduced the amount and complexity of the code.
515 In general, the style was intended as a practical example for
516 this style overview document, and not to be a part of Qt
517 itself.
518
519 Not all widgets have every state implemented. This goes for
520 states that are common, e.g., State_Disabled. Each state is,
521 however, implemented for at least one widget.
522
523 We have only implemented ticks below the slider. Flat push
524 buttons are also left out. We do not handle the case where the
525 title bars and dock window titles grows to small for their
526 contents, but simply draw sub controls over each other.
527
528 We have not tried to emulate the Java fonts. Java and Qt use very
529 different font engines, so we don't consider it worth the effort
530 as we only use the style as an example for this overview.
531
532 We have hardcoded the colors (we don't use the QPalette) for
533 the linear gradients, which are used, for example, for button
534 bevels, tool bars, and check boxes. This is because the Java
535 palette cannot produce these colors. Java does not change these
536 colors based on widget color group or role anyway (they are not
537 dependent on the palette), so it does not present a problem in any
538 case.
539
540 It is Qt's widgets that are styled. Some widgets do not exist
541 at all in Java, e.g., QToolBox. Others contain elements that the
542 Java widgets don't. The tree widget is an example of the latter in
543 which Java's JTree does not have a header.
544
545 The style does not handle reverse layouts. We assume that the
546 layout direction is left to right. QWindowsStyle handles reverse
547 widgets; if we implemented reverse layouts, widgets that we change
548 the position of sub elements, or handle text alignment in labels
549 our selves would need to be updated.
550
551 \section2 Styling Java Check Boxes
552
553 As an example, we will examine the styling of check boxes in the
554 java style. We describe the complete process and print all code in
555 both the java style and Qt classes involved. In the rest of this
556 document, we will not examine the source code of the individual
557 widgets. Hopefully, this will give you an idea on how to search
558 through the code if you need to check specific implementation
559 details; most widgets follow the same structure as the check
560 boxes. We have edited the QCommonStyle code somewhat to remove
561 code that is not directly relevant for check box styling.
562
563 We start with a look at how QCheckBox builds it style option,
564 which is QStyleOptionButton for checkboxes:
565
566 \snippet doc/src/snippets/code/doc_src_styles.qdoc 0
567
568 First we let QStyleOption set up the option with the information
569 that is common for all widgets with \c initFrom(). We will look at
570 this shortly.
571
572 The down boolean is true when the user press the box down; this is
573 true whether the box is checked or not of the checkbox. The
574 State_NoChange state is set when we have a tristate checkbox and
575 it is partially checked. It has State_On if the box is checked and
576 State_Off if it is unchecked. State_MouseOver is set if the mouse
577 hovers over the checkbox and the widget has attribute Qt::WA_Hover
578 set - you set this in QStyle::polish(). In addition, the style
579 option also contains the text, icon, and icon size of the button.
580
581 \l{QStyleOption::}{initFrom()} sets up the style option with the
582 attributes that are common for all widgets. We print its
583 implementation here:
584
585 \snippet doc/src/snippets/code/doc_src_styles.qdoc 1
586
587 The State_Enabled is set when the widget is enabled. When the
588 widget has focus the State_HasFocus flag is set. Equally, the
589 State_Active flag is set when the widget is a child of the active
590 window. The State_MouseOver will only be set if the widget has
591 the WA_HoverEnabled windows flag set. Notice that keypad
592 navigation must be enabled in Qt for the State_HasEditFocus to
593 be included; it is not included by default.
594
595 In addition to setting state flags the QStyleOption contains
596 other information about the widget: \c direction is the layout
597 direction of the layout, \c rect is the bounding rectangle of the
598 widget (the area in which to draw), \c palette is the QPalette
599 that should be used for drawing the widget, and \c fontMetrics is
600 the metrics of the font that is used by the widget.
601
602 We give an image of a checkbox and the style option to match
603 it.
604
605 \image javastyle/checkboxexample.png A java style checkbox
606
607 The above checkbox will have the following state flags in its
608 style option:
609
610 \table 90%
611 \header
612 \o State flag
613 \o Set
614 \row
615 \o State_Sunken
616 \o Yes
617 \row
618 \o State_NoChange
619 \o No
620 \row
621 \o State_On
622 \o Yes
623 \row
624 \o State_Off
625 \o No
626 \row
627 \o State_MouseOver
628 \o Yes
629 \row
630 \o State_Enabled
631 \o Yes
632 \row
633 \o State_HasFocus
634 \o Yes
635 \row
636 \o State_KeyboardFocusChange
637 \o No
638 \row
639 \o State_Active
640 \o Yes
641 \endtable
642
643 The QCheckBox paints itself in QWidget::paintEvent() with
644 style option \c opt and QStylePainter \c p. The QStylePainter
645 class is a convenience class to draw style elements. Most
646 notably, it wraps the methods in QStyle used for painting. The
647 QCheckBox draws itself as follows:
648
649 \snippet doc/src/snippets/code/doc_src_styles.qdoc 2
650
651 QCommonStyle handles the CE_CheckBox element. The QCheckBox
652 has two sub elements: SE_CheckBoxIndicator (the checked indicator)
653 and SE_CheckBoxContents (the contents, which is used for the
654 checkbox label). QCommonStyle also implements these sub element
655 bounding rectangles. We have a look at the QCommonStyle code:
656
657 \snippet doc/src/snippets/code/doc_src_styles.qdoc 3
658
659 As can be seen from the code extract, the common style gets
660 the bounding rectangles of the two sub elements of
661 CE_CheckBox, and then draws them. If the checkbox has focus,
662 the focus frame is also drawn.
663
664 The java style draws CE_CheckBoxIndicator, while QCommonStyle
665 handles CE_CheckboxLabel. We will examine each implementation and
666 start with CE_CheckBoxLabel:
667
668 \snippet doc/src/snippets/code/doc_src_styles.qdoc 4
669
670 \l{QStyle::}{visualAlignment()} adjusts the alignment of text
671 according to the layout direction. We then draw an icon if it
672 exists, and adjust the space left for the text.
673 \l{QStyle::}{drawItemText()} draws the text taking alignment,
674 layout direction, and the mnemonic into account. It also uses the
675 palette to draw the text in the right color.
676
677 The drawing of labels often get somewhat involved. Luckily, it
678 can usually be handled by the base class. The java style
679 implements its own push button label since Java-contrary to
680 windows-center button contents also when the button has an icon.
681 You can examine that implementation if you need an example of
682 reimplementing label drawing.
683
684 We take a look at the java implementation
685 of CE_CheckBoxIndicator in \c drawControl():
686
687 \snippet doc/src/snippets/javastyle.cpp 0
688
689 We first save the state of the painter. This is not always
690 necessary but in this case the QWindowsStyle needs the painter in
691 the same state as it was when PE_IndicatorCheckBox was called (We
692 could also set the state with function calls, of course). We then
693 use \c drawButtonBackground() to draw the background of the check
694 box indicator. This is a helper function that draws the background
695 and also the frame of push buttons and check boxes. We take a look
696 at that function below. We then check if the mouse is hovering
697 over the checkbox. If it is, we draw the frame java checkboxes
698 have when the box is not pressed down and the mouse is over it.
699 You may note that java does not handle tristate boxes, so we have
700 not implemented it.
701
702 Here we use a png image for our indicator. We could also check
703 here if the widget is disabled. We would then have to use
704 another image with the indicator in the disabled color.
705
706 \snippet doc/src/snippets/javastyle.cpp 1
707
708 We have seen how check boxes are styled in the java style from the
709 widget gets a paint request to the style is finished painting. To
710 learn in detail how each widget is painted, you need to go through
711 the code step-by-step as we have done here. However, it is
712 usually enough to know which style elements the widgets draw. The
713 widget builds a style option and calls on the style one or more
714 times to draw the style elements of which it consists. Usually,
715 it is also sufficient to know the states a widget can be in and the
716 other contents of the style option, i.e., what we list in the next
717 section.
718
719 \section1 Widget Walkthrough
720
721 In this section, we will examine how most of Qt's widgets are
722 styled. Hopefully, this will save you some time and effort while
723 developing your own styles and widgets. You will not find
724 information here that is not attainable elsewhere (i.e., by
725 examining the source code or the class descriptions for the style
726 related classes).
727
728 We mostly use java style widgets as examples. The java style does not
729 draw every element in the element trees. This is because they are
730 not visible for that widget in the java style. We still make sure
731 that all elements are implemented in a way that conforms with the
732 java style as custom widgets might need them (this does not
733 exclude leaving implementations to QWindowsStyle though).
734
735 The following is given for each widget:
736
737 \list
738 \o A table with the members (variables, etc.) of its style option.
739 \o A table over the state flags (QStyle::StateFlag) that
740 can be set on the widget and when the states are set.
741 \o Its element tree (see section \l{The Style Elements}).
742 \o An image of the widget in which the elements are outlined.
743 \omit This is not written yet - probably never will be
744 either
745 \o List of style hints that should be checked for the
746 widget.
747 \o List of standard pixmaps that could be used by the
748 elements.
749 \endomit
750 \endlist
751
752 The element tree contains the primitive, control, and complex
753 style elements. By doing a top-down traversal of the element tree,
754 you get the sequence in which the elements should be drawn. In the
755 nodes, we have written the sub element rectangles, sub control
756 elements, and pixel metrics that should be considered when drawing
757 the element of the node.
758
759 Our approach on styling center on the drawing of the widgets. The
760 calculations of sub elements rectangles, sub controls, and pixel
761 metrics used \bold during drawing is only listed as contents in
762 the element trees. Note that there are rectangles and pixel
763 metrics that are only used by widgets. This leaves these
764 calculations untreated in the walkthrough. For instance, the
765 \l{QStyle::}{subControlRect()} and
766 \l{QStyle::}{sizeFromContents()} functions often call
767 \l{QStyle::}{subElementRect()} to calculate their bounding
768 rectangles. We could draw trees for this as well. However, how
769 these calculations are done is completely up to the individual
770 styles, and they do not have to follow a specific structure (Qt
771 does not impose a specific structure). You should still make sure
772 that you use the appropriate pixel metrics, though. To limit the
773 size of the document, we have therefore chosen not to include
774 trees or describe the calculations made by the Java (or any other)
775 style.
776
777 You may be confused about how the different pixel metrics, sub
778 element rectangles, and sub control rectangles should be used when
779 examining the trees. If you are in doubt after reading the QStyle
780 enum descriptions, we suggest that you examine the QCommonStyle
781 and QWindowsStyle implementations.
782
783 Some of the bounding rectangles that we outline in the widget
784 images are equal. Reasons for this are that some elements draw
785 backgrounds while others draw frames and labels. If in doubt,
786 check the description of each element in QStyle. Also, some
787 elements are there to layout, i.e., decide where to draw, other
788 elements.
789
790 \section2 Common Widget Properties
791
792 Some states and variables are common for all widgets. These are
793 set with QStyleOption::initFrom(). Not all elements use this function;
794 it is the widgets that create the style options, and for some
795 elements the information from \l{QStyleOption::}{initFrom()} is not
796 necessary.
797
798 A table with the common states follows:
799
800 \table 90%
801 \header
802 \o State
803 \o State Set When
804 \row
805 \o State_Enabled
806 \o Set if the widget is not disabled (see
807 QWidget::setEnabled())
808 \row
809 \o State_Focus
810 \o Set if the widget has focus (see
811 QWidget::hasFocus())
812 \row
813 \o State_KeyobordFocusChange
814 \o Set when the user changes focus with the keyboard
815 (see Qt::WA_KeyboardFocusChange)
816 \row
817 \o State_MouseOver
818 \o Set if the mouse cursor is over the widget
819 \row
820 \o State_Active
821 \o Set if the widget is a child of the active window.
822 \row
823 \o State_HasEditFocus
824 \o Set if the widget has the edit focus
825 \endtable
826
827 The other common members for widgets are:
828
829 \table 90%
830 \header
831 \o Member
832 \o Content
833 \row
834 \o rect
835 \o The bounding rectangle of the element to draw. This
836 is set to the widget bounding rectangle
837 (QWidget::rect()).
838 \row
839 \o direction
840 \o The layout direction; a value of the
841 Qt::LayoutDirection enum.
842 \row
843 \o palette
844 \o The QPalette to use when drawing the element. This
845 is set to the widgets palette (QWidget::palette()).
846 \row
847 \o fontMetrics
848 \o The QFontMetrics to use when drawing text on the
849 widget.
850 \endtable
851
852 The complex style options (classes that inherit
853 QStyleOptionComplex) used for complex style elements share two
854 variables: \l{QStyleOptionComplex::}{subControls} and
855 \l{QStyleOptionComplex::}{activeSubControls}. Both variables are
856 an OR'ed combination of QStyle::SubControl enum values. They
857 indicate which sub controls the complex control consists of and
858 which of these controls are currently active.
859
860 As mentioned, the style calculates the size of the widgets
861 contents, which the widgets calculate their size hints from. In
862 addition, complex controls also use the style to test which
863 sub-controls the mouse is over.
864
865 \section2 Widget Reference
866
867 Without further delay, we present the widget walkthrough; each
868 widget has its own sub-section.
869
870 \section3 Push Buttons
871
872 The style structure for push buttons is shown below. By doing a
873 top-down traversal of the tree, you get the sequence in which the
874 elements should be drawn.
875
876 \image javastyle/pushbutton.png The style structure for push buttons
877
878 The layout of the buttons, with regard element bounds, varies from
879 style to style. This makes it difficult to show conceptual images
880 of this. Also, elements may - even be intended to - have the same
881 bounds; the PE_PushButtonBevel, for instance, is used in
882 QCommonStyle to draw the elements that contains it:
883 PE_FrameDefaultButton, PE_FrameButtonBevel, and
884 PE_PanelButtonCommand, all of which have the same bounds in common
885 and windows style. PE_PushButtonBevel is also responsible for
886 drawing the menu indicator (QCommonStyle draws
887 PE_IndicatorArrowDown).
888
889 An image of a push button in the java style that show the bounding
890 rectangles of the elements is given below. Colors are used to
891 separate the bounding rectangles in the image; they do not fill
892 any other purpose. This is also true for similar images for the
893 other widgets.
894
895 \image javastyle/button.png
896
897 The java style, as well as all other styles implemented in Qt,
898 does not use PE_FrameButtonBevel. It is usual that a button
899 with a PE_DefaultFrame adjusts the PE_PanelButtonCommand's
900 rectangle by PM_ButtonDefaultIndicator. The CE_PushButtonLabel
901 is found by adjusting the rect by PM_DefaultFrameWidth.
902
903 We will now examine the style option for push
904 buttons - QStyleOptionButton. A table for the states that
905 QPushButton can set on the style option follows:
906
907 \table 90%
908 \header
909 \o State
910 \o State Set When
911 \row
912 \o State_Sunken
913 \o Button is down or menu is pressed shown
914 \row
915 \o State_On
916 \o Button is checked
917 \row
918 \o State_Raised
919 \o Button is not flat and not pressed down
920 \endtable
921
922 Other members of QStyleOptionButton is:
923
924 \table 90%
925 \header
926 \o Member
927 \o Content
928 \row
929 \o features
930 \o Flags of the QStyleOptionButton::ButtonFeatures enum,
931 which describes various button properties (see enum)
932 \row
933 \o icon
934 \o The buttons QIcon (if any)
935 \row
936 \o iconSize
937 \o The QSize of the icon
938 \row
939 \o text
940 \o a QString with the buttons text
941 \endtable
942
943 \section3 Check and Radio Buttons
944
945 The structures for radio and check buttons are identical.
946 We show the structure using QCheckBox element and pixel
947 metric names:
948
949 \image javastyle/checkbox.png
950
951 QStyleOptionButton is used as the style option for both check
952 and radio buttons. We first give a table of the states that
953 can be set in the option:
954
955 \table 90%
956 \header
957 \o State
958 \o State Set When
959 \row
960 \o State_sunken
961 \o The box is pressed down
962 \row
963 \o State_NoChange
964 \o The box is partially checked (for tristate
965 checkboxes.)
966 \row
967 \o State_On
968 \o The box is checked
969 \row
970 \o State_Off
971 \o The box is unchecked
972 \endtable
973
974 See \l{Push Buttons} for a table over other members in the
975 QStyleOptionButtonClass.
976
977 \section3 Tabs
978
979 In Qt, QTabBar uses the style to draw its tabs. Tabs exist either
980 in a QTabWidget, which contains a QTabBar, or as a separate bar.
981 If the bar is not part of a tab widget, it draws its own base.
982
983 QTabBar lays out the tabs, so the style does not have control over
984 tab placement. However, while laying out its tabs, the bar asks
985 the style for PM_TabBarTabHSpace and PM_TabBarTabVSpace, which is
986 extra width and height over the minimum size of the tab bar tab
987 label (icon and text). The style can also further influence the
988 tab size before it is laid out, as the tab bar asks for
989 CT_TabBarTab. The bounding rectangle of the bar is decided by the
990 tab widget when it is part of the widget (still considering
991 CT_TabBarTab).
992
993 The tab bar is responsible for drawing the buttons that appear on
994 the tab bar when all tabs do not fit. Their placement is not
995 controlled by the style, but the buttons are \l{QToolButton}s
996 and are therefore drawn by the style.
997
998 Here is the style structure for QTabWidget and QTabBar:
999
1000 \image javastyle/tab.png
1001
1002 The dotted lines indicate that the QTabWidget contains a tab bar,
1003 but does not draw it itself, that QTabBar only draws its base line
1004 when not part of a tab widget, and that the tab bar keeps two tool
1005 buttons that scroll the bar when all tabs do not fit; see \l{Tool
1006 Buttons} for their element tree. Also note that since the buttons
1007 are children of the tab bar, they are drawn after the bar. The
1008 tabs bounding rectangles overlap the base by PM_TabBarBaseOverlap.
1009
1010 Here is a tab widget in the java style:
1011
1012 \image javastyle/tabwidget.png
1013
1014 In the java style (and also windows), the tab bar shape and label
1015 have the same bounding rectangle as CE_TabBarTab. Notice that the
1016 tabs overlap with the tab widget frame. The base of the tab bar
1017 (if drawn) is the area where the tabs and frame overlap.
1018
1019 The style option for tabs (QStyleOptionTab) contains the necessary
1020 information for drawing tabs. The option contains the position of
1021 the tab in the tab bar, the position of the selected tab, the
1022 shape of the tab, the text, and icon. After Qt 4.1 the option
1023 should be cast to a QStyleOptionTabV2, which also contains the
1024 icons size.
1025
1026 As the java style tabs don't overlap, we also present an image of
1027 a tab widget in the windows style. Note that if you want the tabs
1028 to overlap horizontally, you do that when drawing the tabs in
1029 CE_TabBarTabShape; the tabs bounding rectangles will not be
1030 altered by the tab bar. The tabs are drawn from left to right in a
1031 north tab bar shape, top to bottom in an east tab bar shape, etc.
1032 The selected tab is drawn last, so that it is easy to draw it over
1033 the other tabs (if it is to be bigger).
1034
1035 \image javastyle/windowstabimage.png
1036
1037 A table of the states a tab bar can set on its tabs follows:
1038
1039 \table 90%
1040 \header
1041 \o State
1042 \o State Set When
1043 \row
1044 \o State_Sunken
1045 \o The tab is pressed on with the mouse.
1046 \row
1047 \o State_Selected
1048 \o If it is the current tab.
1049 \row
1050 \o State_HasFocus
1051 \o The tab bar has focus and the tab is selected
1052 \endtable
1053
1054 Note that individual tabs may be disabled even if the tab bar
1055 is not. The tab will be active if the tab bar is active.
1056
1057 Here follows a table of QStyleOptionTabV2's members:
1058
1059 \table 90%
1060 \header
1061 \o Member
1062 \o Content
1063 \row
1064 \o cornerWidgets
1065 \o Is flags of the CornerWidget enum, which indicate
1066 if and which corner widgets the tab bar has.
1067 \row
1068 \o icon
1069 \o The QIcon of the tab
1070 \row
1071 \o iconSize
1072 \o The QSize of the icon
1073 \row
1074 \o position
1075 \o A TabPosition enum value that indicates the tabs
1076 position on the bar relative to the other tabs.
1077 \row
1078 \o row
1079 \o holds which row the tab is in
1080 \row
1081 \o selectedPosition
1082 \o A value of the SelectedPosition enum that indicates
1083 whether the selected tab is adjacent to or is the
1084 tab.
1085 \row
1086 \o shape
1087 \o A value of the QTabBar::Shape enum indication
1088 whether the tab has rounded or triangular corners
1089 and the orientation of the tab.
1090 \row
1091 \o text
1092 \o The tab text
1093 \endtable
1094
1095 The frame for tab widgets use QStyleOptionTabWidgetFrame as
1096 style option. We list its members here. It does not have
1097 states set besides the common flags.
1098
1099 \table 90%
1100 \header
1101 \o Member
1102 \o content
1103 \row
1104 \o leftCornerWidgetSize
1105 \o The QSize of the left corner widget (if any).
1106 \row
1107 \o rightCornerWidgetSize
1108 \o The QSize of the right corner widget (if any).
1109 \row
1110 \o lineWidth
1111 \o holds the line with for drawing the panel.
1112 \row
1113 \o midLineWith
1114 \o this value is currently always 0.
1115 \row
1116 \o shape
1117 \o The shape of the tabs on the tab bar.
1118 \row
1119 \o tabBarSize
1120 \o The QSize of the tab bar.
1121 \endtable
1122
1123 \section3 Scroll Bars
1124
1125 Here is the style structure for scrollBars:
1126
1127 \image javastyle/scrollbar.png
1128
1129 QScrollBar simply creates its style option and then draws
1130 CC_ScrollBar. Some styles draw the background of add page and sub
1131 page with PE_PanelButtonBevel and also use indicator arrows to
1132 draw the arrows in the nest and previous line indicators; we have
1133 not included these in the tree as their use is up to the
1134 individual style. The style's PM_MaximumDragDistance is the
1135 maximum distance in pixels the mouse can move from the bounds
1136 of the scroll bar and still move the handle.
1137
1138 Here is an image of a scrollbar in the java style:
1139
1140 \image javastyle/scrollbarimage.png
1141
1142 You may notice that the scrollbar is slightly different from
1143 Java's as it has two line up indicators. We have done this to show
1144 how that you can have two separate bounding rectangles for a
1145 single sub control. The scroll bar is an example of a widget that
1146 is entirely implemented by the java style - neither QWindowsStyle
1147 nor QCommonStyle are involved in the drawing.
1148
1149 We have a look at the different states a scroll bar can set on
1150 the style option:
1151
1152 \table 90%
1153 \header
1154 \o State
1155 \o State Set When
1156 \row
1157 \o State_Horizontal
1158 \o The scroll bar is horizontal
1159 \endtable
1160
1161 The style option of QScrollBar is QStyleOptionSlider. Its
1162 members are listed in the following table. The option is used
1163 by all \l{QAbstractSlider}s; we only describe the members
1164 relevant for scroll bars here.
1165
1166 \table 90%
1167 \header
1168 \o Member
1169 \o Content
1170 \row
1171 \o maximum
1172 \o the maximum value of the scroll bar
1173 \row
1174 \o minimum
1175 \o the minimum value of the scroll bar
1176 \row
1177 \o notchTarget
1178 \o the number of pixels between notches
1179 \row
1180 \o orientation
1181 \o a value of the Qt::Orientation enum that specifies
1182 whether the scroll bar is vertical or horizontal
1183 \row
1184 \o pageStep
1185 \o the number to increase or decrease the sliders
1186 value (relative to the size of the slider and its value
1187 range) on page steps.
1188 \row
1189 \o singleStep
1190 \o the number to increase or decrease the sliders
1191 value on single (or line) steps
1192 \row
1193 \o sliderValue
1194 \o The value of the slider
1195 \row
1196 \o sliderPosition
1197 \o the position of the slider handle. This is the same
1198 as \c sliderValue if the scroll bar is
1199 QAbstractSlider::tracking. If not, the scroll
1200 bar does not update its value before the mouse
1201 releases the handle.
1202 \row
1203 \o upsideDown
1204 \o holds the direction in which the scroll bar
1205 increases its value. This is used instead of
1206 QStyleOption::direction for all abstract sliders.
1207 \endtable
1208
1209 \section3 Sliders
1210
1211 When calculating the sliders size hint, PM_SliderTickness and
1212 PM_SliderLength is queried from the style. As with scroll bars,
1213 the QSlider only lets the user move the handle if the mouse is
1214 within PM_MaximumDragDistance from the slider bounds. When it
1215 draws itself it creates the style option and calls \c
1216 drawComplexControl() with CC_Slider:
1217
1218 \image javastyle/slider.png
1219
1220 We also show a picture of a slider in the java style. We show
1221 the bounding rectangles of the sub elements as all drawing is done
1222 in CC_Slider.
1223
1224 \image javastyle/sliderimage.png
1225
1226 QSlider uses QStyleOptionSlider as all \l{QAbstractSlider}s do. We
1227 present a table with the members that affect QSlider:
1228
1229 \table 90%
1230 \header
1231 \o Member
1232 \o Content
1233 \row
1234 \o maximum
1235 \o the maximum value of the slider
1236 \row
1237 \o minimum
1238 \o the minimum value of the slider
1239 \row
1240 \o notchTarget
1241 \o this is the number of pixels between each notch
1242 \row
1243 \o orientation
1244 \o a Qt::Orientation enum value that gives whether the
1245 slider is vertical or horizontal.
1246 \row
1247 \o pageStep
1248 \o a number in slider value to increase or decrease
1249 for page steps
1250 \row
1251 \o singleStep
1252 \o the number to increase or decrease the sliders
1253 value on single (or line) steps.
1254 \row
1255 \o sliderValue
1256 \o the value of the slider.
1257 \row
1258 \o sliderPosition
1259 \o the position of the slider given as a slider value.
1260 This will be equal to the \c sliderValue if the
1261 slider is \l{QAbstractSlider::}{tracking}; if
1262 not, the sliders value will not change until the handle is
1263 released with the mouse.
1264 \row
1265 \o upsideDown
1266 \o this member is used instead of QStyleOption::direction
1267 for all abstract sliders.
1268 \endtable
1269
1270 You should note that the slider does not use direction for
1271 reverse layouts; it uses \c upsideDown.
1272
1273 \section3 Spin Boxes
1274
1275 When QSpinBox paints itself it creates a QStyleOptionSpinBox and
1276 asks the style to draw CC_SpinBox. The edit field is a line
1277 edit that is a child of the spin box. The dimensions of the
1278 field is calculated by the style with SC_SpinBoxEditField.
1279
1280 Here follows the style tree for spin boxes. It is not
1281 required that a style uses the button panel primitive to paint
1282 the indicator backgrounds. You can see an image below the tree
1283 showing the sub elements in QSpinBox in the java style.
1284
1285 \image javastyle/spinbox.png
1286
1287 \image javastyle/spinboximage.png
1288
1289 The QStyleOptionSpinBox, which is the style option for spin
1290 boxes. It can set the following states on the spin box.:
1291
1292 \table 90%
1293 \header
1294 \o State
1295 \o State Set When
1296 \row
1297 \o State_Sunken
1298 \o Is set if one of the sub controls CC_SpinUp or
1299 CC_SpinDown is pressed on with the mouse.
1300 \endtable
1301
1302 The rest of the members in the spin boxes style options are:
1303
1304 \table 90%
1305 \header
1306 \o Property
1307 \o Function
1308 \row
1309 \o frame
1310 \o boolean that is true if the spin box is to draw a
1311 frame.
1312 \row
1313 \o buttonSymbols
1314 \o Value of the ButtonSymbols enum that decides the
1315 symbol on the up/down buttons.
1316 \row
1317 \o stepEnabled
1318 \o A value of the StepEnabled indication which of the
1319 spin box buttons are pressed down.
1320 \endtable
1321
1322 \section3 Title Bar
1323
1324 The title bar complex control, CC_TitleBar, is used to draw
1325 the title bars of internal windows in QMdiArea. It typically
1326 consists of a window title and close, minimize, system menu, and
1327 maximize buttons. Some styles also provide buttons for shading
1328 the window, and a button for context sensitive help.
1329
1330 The bar is drawn in CC_TitleBar without using any sub elements.
1331 How the individual styles draw their buttons is individual, but
1332 there are standard pixmaps for the buttons that the style should
1333 provide.
1334
1335 \image javastyle/titlebar.png
1336
1337 In an image over a title bar in the java style, we show the
1338 bounding rectangles of the sub elements supported by the java style
1339 (all of which are drawn with standard pixmaps). It is usual to
1340 draw the button backgrounds using PE_PanelButtonTool, but it's no
1341 rule.
1342
1343 \image javastyle/titlebarimage.png
1344
1345 The style option for title bars is QStyleOptionTitleBar. It's
1346 members are:
1347
1348 \table 90%
1349 \header
1350 \o Member
1351 \o Content
1352 \row
1353 \o icon
1354 \o The title bars icon
1355 \row
1356 \o text
1357 \o the text for the title bar's label
1358 \row
1359 \o windowFlags
1360 \o flags of the Qt::WindowFlag enum. The window flags
1361 used by QMdiArea for window management.
1362 \row
1363 \o titleBarState
1364 \o this is the QWidget::windowState() of the window
1365 that contains the title bar.
1366 \endtable
1367
1368 \section3 Combo Box
1369
1370 A QComboBox uses the style to draw the button and label of
1371 non-editable boxes with CC_ComboBox and CE_ComboBoxLabel.
1372
1373 The list that pops up when the user clicks on the combo box is
1374 drawn by a \l{Delegate Classes}{delegate}, which we do not cover
1375 in this overview. You can, however, use the style to control the
1376 list's size and position with the sub element
1377 SC_ComboBoxListBoxPopup. The style also decides where the edit
1378 field for editable boxes should be with SC_ComboBoxEditField; the
1379 field itself is a QLineEdit that is a child of the combo box.
1380
1381 \image javastyle/combobox.png
1382
1383 We show an image over a java style combo box in which we have
1384 outlined its sub elements and sub element rectangles:
1385
1386 \image javastyle/comboboximage.png
1387
1388 Java combo boxes do not use the focus rect; it changes its
1389 background color when it has focus. The SC_ComboBoxEdit field is
1390 used both by QComboBox to calculate the size of the edit field and
1391 the style for calculating the size of the combo box label.
1392
1393 The style option for combo boxes is QStyleOptionComboBox. It
1394 can set the following states:
1395
1396 \table 90%
1397 \header
1398 \o State
1399 \o Set When
1400 \row
1401 \o State_Selected
1402 \o The box is not editable and has focus
1403 \row
1404 \o State_Sunken
1405 \o SC_ComboBoxArrow is active
1406 \row
1407 \o State_on
1408 \o The container (list) of the box is visible
1409 \endtable
1410
1411 The style options other members are:
1412
1413 \table
1414 \header
1415 \o Member
1416 \o Content
1417 \row
1418 \o currentIcon
1419 \o the icon of the current (selected) item of the
1420 combo box.
1421 \row
1422 \o currentText
1423 \o the text of the current item in the box.
1424 \row
1425 \o editable
1426 \o holds whether the combo box is editable or not
1427 \row
1428 \o frame
1429 \o holds whether the combo box has a frame or not
1430 \row
1431 \o iconSize
1432 \o the size of the current items icon.
1433 \row
1434 \o popupRect
1435 \o the bounding rectangle of the combo box's popup
1436 list.
1437 \endtable
1438
1439 \section3 Group Boxes
1440
1441 When calculating the size hint, QGroupBox fetches three pixel
1442 metrics from the style: PM_IndicatorWidth,
1443 PM_CheckBoxLabelSpacing, and PM_IndicatorHeight. QGroupBox has
1444 the following style element tree:
1445
1446 \image javastyle/groupbox.png
1447
1448 Qt does not impose restrictions on how the check box is drawn; the
1449 java style draws it with CE_IndicatorCheckBox. See \l{Check and
1450 Radio Buttons} for the complete tree.
1451
1452 We also give an image of the widget with the sub controls and
1453 sub control rectangles drawn:
1454
1455 \image javastyle/groupboximage.png
1456
1457 The style option for group boxes are QStyleOptionGroupBox. The
1458 following states can be set on it:
1459
1460 \table 90%
1461 \header
1462 \o State
1463 \o Set When
1464 \row
1465 \o State_On
1466 \o The check box is checked
1467 \row
1468 \o State_Sunken
1469 \o The checkbox is pressed down
1470 \row
1471 \o State_Off
1472 \o The check box is unchecked (or there is no check box)
1473 \endtable
1474
1475 The remaining members of QStyleOptionGroupBox are:
1476
1477 \table
1478 \header
1479 \o Member
1480 \o Content
1481 \row
1482 \o features
1483 \o flags of the QStyleOptionFrameV2::FrameFeatures
1484 enum describing the frame of the group box.
1485 \row
1486 \o lineWidth
1487 \o the line width with which to draw the panel. This
1488 is always 1.
1489 \row
1490 \o text
1491 \o the text of the group box.
1492 \row
1493 \o textAlignment
1494 \o the alignment of the group box title
1495 \row
1496 \o textColor
1497 \o the QColor of the text
1498 \endtable
1499
1500 \section3 Splitters
1501
1502 As the structure of splitters are simple and do not contain any
1503 sub elements, we do not include image of splitters. CE_Splitter
1504 does not use any other elements or metrics.
1505
1506 For its style option, Splitters uses the base class QStyleOption.
1507 It can set the following state flags on it:
1508
1509 \table 90%
1510 \header
1511 \o State
1512 \o Set When
1513 \row
1514 \o State_Horizontal
1515 \o Set if it is a horizontal splitter
1516 \endtable
1517
1518 QSplitter does not use \l{QStyleOption::}{initFrom()} to set up its
1519 option; it sets the State_MouseOver and State_Disabled flags
1520 itself.
1521
1522 \section3 Progress Bar
1523
1524 The CE_ProgressBar element is used by QProgressBar, and it is the
1525 only element used by this widget. We start with looking at the
1526 style structure:
1527
1528 \image javastyle/progressbar.png
1529
1530 Here is a progress bar in the windows style (the java style
1531 bounding rectangles are equal):
1532
1533 \image javastyle/progressbarimage.png
1534
1535 The style option for QProgressBar is QStyleOptionProgressBarV2.
1536 The bar does not set any state flags, but the other members of the
1537 option are:
1538
1539 \table 90%
1540 \header
1541 \o Member
1542 \o Content
1543 \row
1544 \o minimum
1545 \o The minimum value of the bar
1546 \row
1547 \o maximum
1548 \o The maximum value of the bar
1549 \row
1550 \o progress
1551 \o The current value of the bar
1552 \row
1553 \o textAlignment
1554 \o How the text is aligned in the label
1555 \row
1556 \o textVisible
1557 \o Whether the label is drawn
1558 \row
1559 \o text
1560 \o The label text
1561 \row
1562 \o orientation
1563 \o Progress bars can be vertical or horizontal
1564 \row
1565 \o invertedAppearance
1566 \o The progress is inverted (i.e., right to left in a
1567 horizontal bar)
1568 \row
1569 \o bottomToTop
1570 \o Boolean that if true, turns the label of vertical
1571 progress bars 90 degrees.
1572 \endtable
1573
1574 \section3 Tool Buttons
1575
1576 Tool buttons exist either independently or as part of tool bars.
1577 They are drawn equally either way. The QToolButton draws only one
1578 style element: CC_ToolButton.
1579
1580 As you must be used to by now (at least if you have read this
1581 document sequentially), we have a tree of the widget's style
1582 structure:
1583
1584 \image javastyle/toolbutton.png
1585
1586 Note that PE_FrameButtonTool and PE_IndicatorArrowDown are
1587 included in the tree as the java style draws them, but they can
1588 safely be omitted if you prefer it. The structure may also be
1589 different. QWindowsStyle, for instance, draws both
1590 PE_IndicatorButtonDropDown and PE_IndicatorArrowDown in
1591 CE_ToolButton.
1592
1593 We also have an image of a tool button where we have outlined
1594 the sub element bounding rectangles and sub controls.
1595
1596 \image javastyle/toolbuttonimage.png
1597
1598 Here is the states table for tool buttons:
1599
1600 \table 90%
1601 \header
1602 \o State
1603 \o Set When
1604 \row
1605 \o State_AutoRise
1606 \o the tool button has the autoRise property set
1607 \row
1608 \o State_raised
1609 \o the button is not sunken (i.e., by being checked or
1610 pressed on with the mouse).
1611 \row
1612 \o State_Sunken
1613 \o the button is down
1614 \row
1615 \o State_On
1616 \o the button is checkable and checked.
1617 \endtable
1618
1619 QStyleOptionToolButton also contains the following members:
1620
1621 \table
1622 \header
1623 \o Member
1624 \o Content
1625 \row
1626 \o arrowType
1627 \o a Qt::ArrowType enum value, which contains the
1628 direction of the buttons arrow (if an arrow is to
1629 be used in place of an icon)
1630 \row
1631 \o features
1632 \o flags of the QStyleOptionToolButton::ButtonFeature
1633 enum describing if the button has an arrow, a menu,
1634 and/or has a popup-delay.
1635 \row
1636 \o font
1637 \o the QFont of the buttons label
1638 \row
1639 \o icon
1640 \o the QIcon of the tool button
1641 \row
1642 \o iconSize
1643 \o the icon size of the button's icon
1644 \row
1645 \o pos
1646 \o the position of the button, as given by
1647 QWidget::pos()
1648 \row
1649 \o text
1650 \o the text of the button
1651 \row
1652 \o toolButtonStyle
1653 \o a Qt::ToolButtonStyle enum value which decides
1654 whether the button shows the icon, the text, or both.
1655 \endtable
1656
1657 \section3 Toolbars
1658
1659 Toolbars are part of the \l{QMainWindow}{main window framework}
1660 and cooperates with the QMainWindow to which it belongs while it
1661 builds its style option. A main window has 4 areas that toolbars
1662 can be placed in. They are positioned next to the four sides of
1663 the window (i.e., north, south, west, and east). Within each area
1664 there can be more than one line of toolbars; a line consists of
1665 toolbars with equal orientation (vertical or horizontal) placed
1666 next to each other.
1667
1668 \l{QToolbar}{QToolbar}s in Qt consists of three elements
1669 CE_ToolBar, PE_IndicatorToolBarHandle, and
1670 PE_IndicatorToolBarSeparator. It is QMainWindowLayout that
1671 calculates the bounding rectangles (i.e., position and size of the
1672 toolbars and their contents. The main window also uses the \c
1673 sizeHint() of the items in the toolbars when calculating the size
1674 of the bars.
1675
1676 Here is the element tree for QToolBar:
1677
1678 \image javastyle/toolbar.png
1679
1680 The dotted lines indicate that the QToolBar keeps an instance of
1681 QToolBarLayout and that QToolBarSeparators are kept by
1682 QToolBarLayout. When the toolbar is floating (i.e., has its own
1683 window) the PE_FrameMenu element is drawn, else QToolbar draws
1684 CE_ToolBar.
1685
1686 Here is an image of a toolbar in the java style:
1687
1688 \image javastyle/toolbarimage.png
1689
1690 QToolBarSaparator uses QStyleOption for their style option. It
1691 sets the State_horizontal flag if the toolbar they live in is
1692 horizontal. Other than that, they use \l{QStyleOption::}{initFrom()}.
1693
1694 The style option for QToolBar is QStyleOptionToolBar. The only
1695 state flag set (besides the common flags) is State_Horizontal
1696 if the bar is horizontal (i.e., in the north or south toolbar area).
1697 The member variables of the style option are:
1698
1699 \table 90%
1700 \header
1701 \o Member
1702 \o Content
1703 \row
1704 \o features
1705 \o Holds whether the bar is movable in a value of the
1706 ToolBarFeature, which is either Movable or None.
1707 \row
1708 \o lineWidth
1709 \o The width of the tool bar frame.
1710 \row
1711 \o midLineWidth
1712 \o This variable is currently not used and is always
1713 0.
1714 \row
1715 \o positionOfLine
1716 \o The position of the toolbar line within the toolbar
1717 area to which it belongs.
1718 \row
1719 \o positionWithinLine
1720 \o The position of the toolbar within the toolbar line.
1721 \row
1722 \o toolBarArea
1723 \o The toolbar area in which the toolbar lives.
1724 \endtable
1725
1726 \section3 Menus
1727
1728 Menus in Qt are implemented in QMenu. The QMenu keeps a list of
1729 action, which it draws as menu items. When QMenu receives paint
1730 events ,it calculates the size of each menu item and draws them
1731 individually with CE_MenuItem. (Menu items do not have a separate
1732 element for their label (contents), so all drawing is done in
1733 CE_MenuItem. The menu also draws the frame of the menu with
1734 PE_FrameMenu. It also draws CE_MenuScroller if the style supports
1735 scrolling. CE_MenuTearOff is drawn if the menu is to large for its
1736 bounding rectangle.
1737
1738 In the style structure tree, we also include QMenu as it also does
1739 styling related work. The bounding rectangles of menu items are
1740 calculated for the menus size hint and when the menu is displayed
1741 or resized.
1742
1743 \image javastyle/menu.png
1744
1745 The CE_MenuScroller and CE_MenuTearOff elements are handled by
1746 QCommonStyle and are not shown unless the menu is to large to fit
1747 on the screen. PE_FrameMenu is only drawn for pop-up menus.
1748
1749 QMenu calculates rectangles based on its actions and calls
1750 CE_MenuItem and CE_MenuScroller if the style supports that.
1751
1752 It is also usual to use PE_IndicatorCheckBox (instead of using
1753 PE_IndicatorMenuCheckMark) and PE_IndicatorRadioButton for drawing
1754 checkable menu items; we have not included them in the style tree
1755 as this is optional and varies from style to style.
1756
1757 \image javastyle/menuimage.png
1758
1759 The style option for menu items is QStyleOptionMenuItem. The
1760 following tables describe its state flags and other members.
1761
1762 \table 90%
1763 \header
1764 \o State
1765 \o Set When
1766 \row
1767 \o State_Selected
1768 \o The mouse is over the action and the action is not
1769 a separator.
1770 \row
1771 \o State_Sunken
1772 \o The mouse is pressed down on the menu item.
1773 \row
1774 \o State_DownArrow
1775 \o Set if the menu item is a menu scroller and it scrolls
1776 the menu downwards.
1777 \endtable
1778
1779 \table 90%
1780 \header
1781 \o Member
1782 \o Content
1783 \row
1784 \o checkType
1785 \o A value of the \l{QStyleOptionMenuItem::}{CheckType} enum,
1786 which is either NotCheckable, Exclusive, or
1787 NonExclusive.
1788 \row
1789 \o checked
1790 \o Boolean that is true if the menu item is checked.
1791 \row
1792 \o font
1793 \o The QFont to use for the menu item's text.
1794 \row
1795 \o icon
1796 \o the QIcon of the menu item.
1797 \row
1798 \o maxIconWidth
1799 \o The maximum width allowed for the icon
1800 \row
1801 \o menuHasChecableItem
1802 \o Boolean which is true if at least one item in the
1803 menu is checkable.
1804 \row
1805 \o menuItemType
1806 \o The type of the menu item. This a value of the
1807 \l{QStyleOptionMenuItem::}{MenuItemType}.
1808 \row
1809 \o menuRect
1810 \o The bounding rectangle for the QMenu that the menu
1811 item lives in.
1812 \row
1813 \o tabWidth
1814 \o This is the distance between the text of the menu
1815 item and the shortcut.
1816 \row
1817 \o text
1818 \o The text of the menu item.
1819 \endtable
1820
1821 The setup of the style option for CE_MenuTearOff and
1822 CE_MenuScroller also uses QStyleOptionMenuItem; they only set the
1823 \c menuRect variable in addition to the common settings with
1824 QStyleOption's \l{QStyleOption::}{initFrom()}.
1825
1826 \section3 Menu Bar
1827
1828 QMenuBar uses the style to draw each menu bar item and the empty
1829 area of the menu bar. The pull-down menus themselves are
1830 \l{QMenu}s (see \l{Menus}). The style element tree for the menu
1831 bar follows:
1832
1833 \image javastyle/menubar.png
1834
1835 The panel and empty area is drawn after the menu items. The
1836 QPainter that the QMenuBar sends to the style has the bounding
1837 rectangles of the items clipped out (i.e., clip region), so you
1838 don't need to worry about drawing over the items. The pixel
1839 metrics in QMenuBar is used when the bounding rectangles of the
1840 menu bar items are calculated.
1841
1842 \image javastyle/menubarimage.png
1843
1844 QStyleOptionMenuItem is used for menu bar items. The members that
1845 are used by QMenuBar is described in the following table:
1846
1847 \table
1848 \header
1849 \o Member
1850 \o Content
1851 \row
1852 \o menuRect
1853 \o the bounding rectangle of the entire menu bar to
1854 which the item belongs.
1855 \row
1856 \o text
1857 \o the text of the item
1858 \row
1859 \o icon
1860 \o the icon of the menu item (it is not common that
1861 styles draw this icon)
1862 \endtable
1863
1864 QStyleOptionMenuItem is also used for drawing CE_EmptyMenuBarArea.
1865
1866 QStyleOptionFrame is used for drawing the panel frame The
1867 \l{QStyleOptionFrame::}{lineWidth} is set to PM_MenuBarPanelWidth.
1868 The \l{QStyleOptionFrame::}{midLineWidth} is currently always set
1869 to 0.
1870
1871 \section3 Item View Headers
1872
1873 It is the style that draws the headers of Qt's item views. The
1874 item views keeps the dimensions on individual sections. Also
1875 note that the delegates may use the style to paint decorations
1876 and frames around items. QItemDelegate, for instance, draws
1877 PE_FrameFocusRect and PE_IndicatorViewItemCheck.
1878
1879 \image javastyle/header.png
1880
1881 Here is a QTableWidget showing the bounding rects of a Java
1882 header:
1883
1884 \image javastyle/headerimage.png
1885
1886 The QHeaderView uses CT_HeaderSection, PM_HeaderMargin and
1887 PM_HeaderGripMargin for size and hit test calculations. The
1888 PM_HeaderMarkSize is currently not used by Qt. QTableView draws
1889 the button in the top-left corner (i.e., the area where the
1890 vertical and horizontal headers intersect) as a CE_Header.
1891
1892 The style option for header views is QStyleOptionHeader. The view
1893 paints one header section at a time, so the data is for the
1894 section being drawn. Its contents are:
1895
1896 \table 90%
1897 \header
1898 \o Member
1899 \o Content
1900 \row
1901 \o icon
1902 \o the icon of the header (for section that is being
1903 drawn).
1904 \row
1905 \o iconAlignment
1906 \o the alignment (Qt::Alignment) of the icon in the header.
1907 \row
1908 \o orientation
1909 \o a Qt::Orientation value deciding whether the header
1910 is the horizontal header above the view or the
1911 vertical header on the left.
1912 \row
1913 \o position
1914 \o a QStyleOptionHeader::SectionPosition value
1915 giving the header section's position relative to
1916 the other sections.
1917 \row
1918 \o section
1919 \o holds the section that is being drawn.
1920 \row
1921 \o selectedPosition
1922 \o a QStyleOptionHeader::SelectedPosition value giving
1923 the selected section's position relative to the
1924 section that is being painted.
1925 \row
1926 \o sortIndicator
1927 \o a QStyleOptionHeader::SortIndicator value that
1928 describes the direction in which the section's sort
1929 indicator should be drawn.
1930 \row
1931 \o text
1932 \o the text of the currently drawn section.
1933 \row
1934 \o textAlignment
1935 \o the Qt::Alignment of the text within the
1936 headersection.
1937 \endtable
1938
1939 \section3 Tree Branch Indicators
1940
1941 The branch indicators in a tree view is drawn by the style with
1942 PE_IndicatorBranch. We think of indicators here as the indicators
1943 that describe the relationship of the nodes in the tree. The
1944 generic QStyleOption is sent to the style for drawing this
1945 elements. The various branch types are described by states. Since
1946 there are no specific style option, we simply present the states
1947 table:
1948
1949 \table 90%
1950 \header
1951 \o State
1952 \o Set When
1953 \row
1954 \o State_Sibling
1955 \o the node in the tree has a sibling (i.e., there is
1956 another node in the same column).
1957 \row
1958 \o State_Item
1959 \o this branch indicator has an item.
1960 \row
1961 \o State_Children
1962 \o the branch has children (i.e., a new sub-tree can
1963 be opened at the branch).
1964 \row
1965 \o State_Open
1966 \o the branch indicator has an opened sub-tree.
1967 \endtable
1968
1969 The tree view (and tree widget) use the style to draw the branches
1970 (or nodes if you will) of the tree.
1971
1972 QStyleOption is used as the style for PE_IndicatorBranch has state
1973 flags set depending on what type of branch it is.
1974
1975 Since there is no tree structure for branch indicators, we only
1976 present an image of a tree in the java style. Each state is marked
1977 in the image with a rectangle in a specific color (i.e., these
1978 rectangles are not bounding rectangles). All combinations of
1979 states you must be aware of are represented in the image.
1980
1981 \image javastyle/branchindicatorimage.png
1982
1983 \section3 Tool Boxes
1984
1985 PM_SmallIconSize for sizeHints.
1986
1987 QToolBox is a container that keeps a collection of widgets. It has
1988 one tab for each widget and display one of them at a time. The
1989 tool box lays the components it displays (the tool box buttons
1990 and selected widget) in a QVBoxLayout. The style tree for tool
1991 boxes looks like this:
1992
1993 \image javastyle/toolbox.png
1994
1995 We show an image of a tool box in the Plastique style:
1996
1997 \image javastyle/toolboximage.png
1998
1999 All elements have the same bounding rectangles in the
2000 Plastique as well as the other Qt built-in styles.
2001
2002 The style option for tool boxes is QStyleOptionToolBox. It
2003 contains the text and icon of the tool box contents. The only
2004 state set by QToolBox is State_Sunken, which is set when the user
2005 presses a tab down with the mouse. The rest of the
2006 QStyleOptionToolBox members are:
2007
2008 \table 90%
2009 \header
2010 \o Member
2011 \o Content
2012 \row
2013 \o icon
2014 \o the icon on the toolbox tab
2015 \row
2016 \o text
2017 \o the text on the toolbox tab
2018 \endtable
2019
2020 \section3 Size Grip
2021
2022 The size grip calculates its size hint with CT_SizeGrip. The pixel
2023 metric PM_SizeGripSize is currently unused by Qt. The element tree
2024 for and an image in the Plastique style of QSizeGrip follows:
2025
2026 \image javastyle/sizegrip.png
2027
2028 \image javastyle/sizegripimage.png
2029
2030 We show the size grip in a \l{QMainWindow}'s bottom right
2031 corner.
2032
2033 The size grip style option, QStyleOptionSizeGrip, have one
2034 member except the common members from QStyleOption:
2035
2036 \table 90%
2037 \header
2038 \o Member
2039 \o Content
2040 \row
2041 \o corner
2042 \o a Qt::Corner value that describe which corner in a
2043 window (or equivalent) the grip is located.
2044 \endtable
2045
2046 \section3 Rubber Band
2047
2048 The \l{QRubberBand}'s style tree consists of two nodes.
2049
2050 \image javastyle/rubberband.png
2051
2052 We present an image of a Java style window being moved in a
2053 QMdiArea with a rubber band:
2054
2055 \image javastyle/rubberbandimage.png
2056
2057 The style option for rubber bands is QStyleOptionRubberBand.
2058 Its members are:
2059
2060 \table
2061 \header
2062 \o Member
2063 \o Content
2064 \row
2065 \o opaque
2066 \o boolean that is true if the rubber band must be
2067 drawn in an opaque style (i.e., color)
2068 \row
2069 \o shape
2070 \o a QRubberBand::Shape enum value that holds the
2071 shape of the band (which is either a rectangle or a
2072 line)
2073 \endtable
2074
2075 \section3 Dock Widgets
2076
2077 When the dock widget lays out its contents it asks the style for
2078 these pixel metrics: PM_DockWidgetSeparatorExtent,
2079 PM_DockWidgetTitleBarButtonMargin, PM_DockWidgetFrameWidth, and
2080 PM_DockWidgetTitleMargin. It also calculates the bounding
2081 rectangles of the float and close buttons with
2082 SE_DockWidgetCloseButton and SE_DockWidgetFloatButton.
2083
2084 \image javastyle/dockwidget.png
2085
2086 The dotted lines indicate that the sender keeps instances of the
2087 recipient of the arrow (i.e., it is not a style element to draw).
2088 The dock widget only draws PE_frameDockWidget when it is detached
2089 from its main window (i.e., it is a top level window). If it is
2090 docked it draws the indicator dock widget resize handle. We show a
2091 dock widget in both docked and floating state in the plastique
2092 style:
2093
2094 \image javastyle/dockwidgetimage.png
2095
2096 The style option is QStyleOptionDockWidget:
2097
2098 \table 90%
2099 \header
2100 \o Member
2101 \o Content
2102 \row
2103 \o closeable
2104 \o boolean that holds whether the dock window can be
2105 closed
2106 \row
2107 \o floatable
2108 \o boolean that holds whether the dock window can
2109 float (i.e., detach from the main window in which
2110 it lives)
2111 \row
2112 \o movable
2113 \o boolean that holds whether the window is movable
2114 (i.e., can move to other dock widget areas)
2115 \row
2116 \o title
2117 \o the title text of the dock window
2118 \endtable
2119
2120 For the buttons, QStyleOptionButton is used (see \l{Tool Buttons}
2121 for content description). The dock widget resize handle has a
2122 plain QStyleOption.
2123*/
Note: See TracBrowser for help on using the repository browser.