1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \page stylesheet.html
|
---|
44 | \startpage index.html QtReference Documentation
|
---|
45 | \nextpage The Style Sheet Syntax
|
---|
46 | \title Qt Style Sheets
|
---|
47 | \ingroup architecture
|
---|
48 | \brief How to use style sheets to customize the appearance of widgets.
|
---|
49 |
|
---|
50 | \keyword style sheet
|
---|
51 | \keyword stylesheet
|
---|
52 |
|
---|
53 | Qt Style Sheets are a powerful mechanism that allows you to
|
---|
54 | customize the appearance of widgets, in addition to what is
|
---|
55 | already possible by subclassing QStyle. The concepts,
|
---|
56 | terminology, and syntax of Qt Style Sheets are heavily inspired
|
---|
57 | by HTML \l{http://www.w3.org/Style/CSS/}{Cascading Style Sheets
|
---|
58 | (CSS)} but adapted to the world of widgets.
|
---|
59 |
|
---|
60 | Topics:
|
---|
61 |
|
---|
62 | \list
|
---|
63 | \i \l{Overview}
|
---|
64 | \i \l{The Style Sheet Syntax}
|
---|
65 | \tableofcontents{1 The Style Sheet Syntax}
|
---|
66 | \i \l{Qt Designer Integration}
|
---|
67 | \tableofcontents{1 Qt Designer Integration}
|
---|
68 | \i \l{Customizing Qt Widgets Using Style Sheets}
|
---|
69 | \tableofcontents{1 Customizing Qt Widgets Using Style Sheets}
|
---|
70 | \i \l{Qt Style Sheets Reference}
|
---|
71 | \tableofcontents{1 Qt Style Sheets Reference}
|
---|
72 | \i \l{Qt Style Sheets Examples}
|
---|
73 | \tableofcontents{1 Qt Style Sheets Examples}
|
---|
74 | \endlist
|
---|
75 |
|
---|
76 | \target overview
|
---|
77 | \section1 Overview
|
---|
78 |
|
---|
79 | Styles sheets are textual specifications that can be set on the
|
---|
80 | whole application using QApplication::setStyleSheet() or on a
|
---|
81 | specific widget (and its children) using
|
---|
82 | QWidget::setStyleSheet(). If several style sheets are set at
|
---|
83 | different levels, Qt derives the effective style sheet from all
|
---|
84 | of those that are set. This is called cascading.
|
---|
85 |
|
---|
86 | For example, the following style sheet specifies that all
|
---|
87 | \l{QLineEdit}s should use yellow as their background color, and
|
---|
88 | all \l{QCheckBox}es should use red as the text color:
|
---|
89 |
|
---|
90 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 0
|
---|
91 |
|
---|
92 | For this kind of customization, style sheets are much more
|
---|
93 | powerful than QPalette. For example, it might be tempting to set
|
---|
94 | the QPalette::Button role to red for a QPushButton to obtain a
|
---|
95 | red push button. However, this wasn't guaranteed to work for all
|
---|
96 | styles, because style authors are restricted by the different
|
---|
97 | platforms' guidelines and (on Windows XP and Mac OS X) by the
|
---|
98 | native theme engine.
|
---|
99 |
|
---|
100 | Style sheets let you perform all kinds of customizations that are
|
---|
101 | difficult or impossible to perform using QPalette alone. If you
|
---|
102 | want yellow backgrounds for mandatory fields, red text for
|
---|
103 | potentially destructive push buttons, or fancy check boxes, style
|
---|
104 | sheets are the answer.
|
---|
105 |
|
---|
106 | Style sheets are applied on top of the current \l{QStyle}{widget
|
---|
107 | style}, meaning that your applications will look as native as
|
---|
108 | possible, but any style sheet constraints will be taken into
|
---|
109 | consideration. Unlike palette fiddling, style sheets offer
|
---|
110 | guarantees: If you set the background color of a QPushButton to be
|
---|
111 | red, you can be assured that the button will have a red background
|
---|
112 | in all styles, on all platforms. In addition, \l{Qt Designer}
|
---|
113 | provides style sheet integration, making it easy to view the effects
|
---|
114 | of a style sheet in different \l{QStyle}{widget styles}.
|
---|
115 |
|
---|
116 | In addition, style sheets can be used to provide a distinctive
|
---|
117 | look and feel for your application, without having to subclass
|
---|
118 | QStyle. For example, you can specify arbitrary images for radio
|
---|
119 | buttons and check boxes to make them stand out. Using this
|
---|
120 | technique, you can also achieve minor customizations that would
|
---|
121 | normally require subclassing several style classes, such as
|
---|
122 | specifying a \l{QStyle::styleHint()}{style hint}. The
|
---|
123 | \l{widgets/stylesheet}{Style Sheet} example depicted below defines
|
---|
124 | two distinctive style sheets that you can try out and modify at
|
---|
125 | will.
|
---|
126 |
|
---|
127 | \table
|
---|
128 | \row \o \inlineimage stylesheet-coffee-xp.png
|
---|
129 | \o \inlineimage stylesheet-pagefold.png
|
---|
130 | \row \o Coffee theme running on Windows XP
|
---|
131 | \o Pagefold theme running on Windows XP
|
---|
132 | \endtable
|
---|
133 |
|
---|
134 | \table
|
---|
135 | \row \o \inlineimage stylesheet-coffee-cleanlooks.png
|
---|
136 | \o \inlineimage stylesheet-pagefold-mac.png
|
---|
137 | \row \o Coffee theme running on Ubuntu Linux
|
---|
138 | \o Pagefold theme running on Mac OS X
|
---|
139 | \endtable
|
---|
140 |
|
---|
141 | When a style sheet is active, the QStyle returned by QWidget::style()
|
---|
142 | is a wrapper "style sheet" style, \e not the platform-specific style. The
|
---|
143 | wrapper style ensures that any active style sheet is respected and
|
---|
144 | otherwise forwards the drawing operations to the underlying,
|
---|
145 | platform-specific style (e.g., QWindowsXPStyle on Windows XP).
|
---|
146 |
|
---|
147 | Since Qt 4.5, Qt style sheets fully supports Mac OS X.
|
---|
148 |
|
---|
149 | \warning Qt style sheets are currently not supported for custom QStyle
|
---|
150 | subclasses. We plan to address this in some future release.
|
---|
151 | */
|
---|
152 |
|
---|
153 | /*!
|
---|
154 | \page stylesheet-syntax.html
|
---|
155 | \contentspage {Qt Style Sheet}{Contents}
|
---|
156 | \previouspage Qt Style Sheet
|
---|
157 | \nextpage Qt Designer Integration
|
---|
158 | \title The Style Sheet Syntax
|
---|
159 |
|
---|
160 | Qt Style Sheet terminology and syntactic rules are almost
|
---|
161 | identical to those of HTML CSS. If you already know CSS, you can
|
---|
162 | probably skim quickly through this section.
|
---|
163 |
|
---|
164 | \section1 Style Rules
|
---|
165 |
|
---|
166 | Style sheets consist of a sequence of style rules. A \e{style
|
---|
167 | rule} is made up of a selector and a declaration. The
|
---|
168 | \e{selector} specifies which widgets are affected by the rule;
|
---|
169 | the \e{declaration} specifies which properties should be set on
|
---|
170 | the widget. For example:
|
---|
171 |
|
---|
172 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 1
|
---|
173 |
|
---|
174 | In the above style rule, \c QPushButton is the selector and \c{{
|
---|
175 | color: red }} is the declaration. The rule specifies that
|
---|
176 | QPushButton and its subclasses (e.g., \c MyPushButton) should use
|
---|
177 | red as their foreground color.
|
---|
178 |
|
---|
179 | Qt Style Sheet is generally case insensitive (i.e., \c color,
|
---|
180 | \c Color, \c COLOR, and \c cOloR refer to the same property).
|
---|
181 | The only exceptions are class names,
|
---|
182 | \l{QObject::setObjectName()}{object names}, and Qt property
|
---|
183 | names, which are case sensitive.
|
---|
184 |
|
---|
185 | Several selectors can be specified for the same declaration,
|
---|
186 | using commas (\c{,}) to separate the selectors. For example,
|
---|
187 | the rule
|
---|
188 |
|
---|
189 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 2
|
---|
190 |
|
---|
191 | is equivalent to this sequence of three rules:
|
---|
192 |
|
---|
193 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 3
|
---|
194 |
|
---|
195 | The declaration part of a style rule is a list of
|
---|
196 | \tt{\e{property}: \e{value}} pairs, enclosed in braces (\c{{}})
|
---|
197 | and separated with semicolons. For example:
|
---|
198 |
|
---|
199 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 4
|
---|
200 |
|
---|
201 | See the \l{List of Properties} section below for the list of
|
---|
202 | properties provided by Qt widgets.
|
---|
203 |
|
---|
204 | \section1 Selector Types
|
---|
205 |
|
---|
206 | All the examples so far used the simplest type of selector, the
|
---|
207 | Type Selector. Qt Style Sheets support all the
|
---|
208 | \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{selectors
|
---|
209 | defined in CSS2}. The table below summarizes the most useful
|
---|
210 | types of selectors.
|
---|
211 |
|
---|
212 | \table 100%
|
---|
213 | \header
|
---|
214 | \o Selector
|
---|
215 | \o Example
|
---|
216 | \o Explanation
|
---|
217 |
|
---|
218 | \row
|
---|
219 | \o Universal Selector
|
---|
220 | \o \c *
|
---|
221 | \o Matches all widgets.
|
---|
222 |
|
---|
223 | \row
|
---|
224 | \o Type Selector
|
---|
225 | \o \c QPushButton
|
---|
226 | \o Matches instances of QPushButton and of its subclasses.
|
---|
227 |
|
---|
228 | \row
|
---|
229 | \o Property Selector
|
---|
230 | \o \c{QPushButton[flat="false"]}
|
---|
231 | \o Matches instances of QPushButton that are not
|
---|
232 | \l{QPushButton::}{flat}. You may use this selector to test
|
---|
233 | for any Qt property specified using Q_PROPERTY(). In
|
---|
234 | addition, the special \c class property is supported, for
|
---|
235 | the name of the class.
|
---|
236 |
|
---|
237 | This selector may also be used to test dynamic properties.
|
---|
238 | For more information on customization using dynamic properties,
|
---|
239 | refer to \l{Customizing Using Dynamic Properties}.
|
---|
240 |
|
---|
241 | Instead of \c =, you can also use \c ~= to test whether a
|
---|
242 | Qt property of type QStringList contains a given QString.
|
---|
243 |
|
---|
244 | \warning If the value of the Qt property changes after the
|
---|
245 | style sheet has been set, it might be necessary to force a
|
---|
246 | style sheet recomputation. One way to achieve this is to
|
---|
247 | unset the style sheet and set it again.
|
---|
248 |
|
---|
249 | \row
|
---|
250 | \o Class Selector
|
---|
251 | \o \c .QPushButton
|
---|
252 | \o Matches instances of QPushButton, but not of its subclasses.
|
---|
253 |
|
---|
254 | This is equivalent to \c{*[class~="QPushButton"]}.
|
---|
255 |
|
---|
256 | \row
|
---|
257 | \o ID \target ID Selector
|
---|
258 | Selector
|
---|
259 | \o \c{QPushButton#okButton}
|
---|
260 | \o Matches all QPushButton instances whose
|
---|
261 | \l{QObject::objectName}{object name} is \c okButton.
|
---|
262 |
|
---|
263 | \row
|
---|
264 | \o Descendant Selector
|
---|
265 | \o \c{QDialog QPushButton}
|
---|
266 | \o Matches all instances of QPushButton that are descendants
|
---|
267 | (children, grandchildren, etc.) of a QDialog.
|
---|
268 |
|
---|
269 | \row
|
---|
270 | \o Child Selector
|
---|
271 | \o \c{QDialog > QPushButton}
|
---|
272 | \o Matches all instances of QPushButton that are direct
|
---|
273 | children of a QDialog.
|
---|
274 | \endtable
|
---|
275 |
|
---|
276 | \section1 Sub-Controls
|
---|
277 |
|
---|
278 | For styling complex widgets, it is necessary to access subcontrols of the
|
---|
279 | widget, such as the drop-down button of a QComboBox or the up and down
|
---|
280 | arrows of a QSpinBox. Selectors may contain \e{subcontrols} that make it
|
---|
281 | possible to restrict the application of a rule to specific widget
|
---|
282 | subcontrols. For example:
|
---|
283 |
|
---|
284 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 5
|
---|
285 |
|
---|
286 | The above rule styles the drop-down button of all \l{QComboBox}es.
|
---|
287 | Although the double-colon (\c{::}) syntax is reminiscent of CSS3
|
---|
288 | Pseudo-Elements, Qt Sub-Controls differ conceptually from these and have
|
---|
289 | different cascading semantics.
|
---|
290 |
|
---|
291 | Sub-controls are always positioned with respect to another element - a
|
---|
292 | reference element. This reference element could be the widget or another
|
---|
293 | Sub-control. For example, the \l{Qt Style Sheets Reference#drop-down-sub}
|
---|
294 | {::drop-down} of a QComboBox is placed, by default, in the top right corner
|
---|
295 | of the Padding rectangle of the QComboBox. The
|
---|
296 | \l{Qt Style Sheets Reference#drop-down-sub}{::drop-down} is placed,
|
---|
297 | by default, in the Center of the Contents rectangle of the
|
---|
298 | \l{Qt Style Sheets Reference#drop-down-sub}{::drop-down} Sub-control. See
|
---|
299 | the \l{List of Stylable Widgets} below for the Sub-controls to use to
|
---|
300 | style a widget and their default positions.
|
---|
301 |
|
---|
302 | The origin rectangle to be used can be changed using the
|
---|
303 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}
|
---|
304 | property. For example, if we want to place the drop-down in the margin
|
---|
305 | rectangle of the QComboBox instead of the default Padding rectangle, we
|
---|
306 | can specify:
|
---|
307 |
|
---|
308 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 6
|
---|
309 |
|
---|
310 | The alignment of the drop-down within the Margin rectangle is changed
|
---|
311 | using \l{Qt Style Sheets Reference#subcontrol-position-prop}
|
---|
312 | {subcontrol-position} property.
|
---|
313 |
|
---|
314 | The \l{Qt Style Sheets Reference#width-prop}{width} and
|
---|
315 | \l{Qt Style Sheets Reference#height-prop}{height} properties can be used
|
---|
316 | to control the size of the Sub-control. Note that setting a
|
---|
317 | \l{Qt Style Sheets Reference#image-prop}{image} implicitly sets the size
|
---|
318 | of a Sub-control.
|
---|
319 |
|
---|
320 | The relative positioning scheme
|
---|
321 | (\l{Qt Style Sheets Reference#position-prop}{position} : relative),
|
---|
322 | allows the position of the Sub-Control to be offset from its initial
|
---|
323 | position. For example, when the QComboBox's drop-down button is
|
---|
324 | pressed, we might like the arrow inside to be offset to give a
|
---|
325 | "pressed" effect. To achieve this, we can specify:
|
---|
326 |
|
---|
327 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 7
|
---|
328 |
|
---|
329 | The absolute positioning scheme
|
---|
330 | (\l{Qt Style Sheets Reference#position-prop}{position} : absolute),
|
---|
331 | allows the position and size of the Sub-control to be changed with
|
---|
332 | respect to the reference element.
|
---|
333 |
|
---|
334 | Once positioned, they are treated the same as widgets and can be styled
|
---|
335 | using the the \l{box model}.
|
---|
336 |
|
---|
337 | See the \l{List of Sub-Controls} below for a list of supported
|
---|
338 | sub-controls, and \l{Customizing the QPushButton's Menu Indicator
|
---|
339 | Sub-Control} for a realistic example.
|
---|
340 |
|
---|
341 | \note With complex widgets such as QComboBox and QScrollBar, if one
|
---|
342 | property or sub-control is customized, \bold{all} the other properties or
|
---|
343 | sub-controls must be customized as well.
|
---|
344 |
|
---|
345 | \section1 Pseudo-States
|
---|
346 |
|
---|
347 | Selectors may contain \e{pseudo-states} that denote that restrict
|
---|
348 | the application of the rule based on the widget's state.
|
---|
349 | Pseudo-states appear at the end of the selector, with a colon
|
---|
350 | (\c{:}) in between. For example, the following rule applies when
|
---|
351 | the mouse hovers over a QPushButton:
|
---|
352 |
|
---|
353 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 8
|
---|
354 |
|
---|
355 | Pseudo-states can be negated using the exclamation operator. For
|
---|
356 | example, the following rule applies when the mouse does not hover
|
---|
357 | over a QRadioButton:
|
---|
358 |
|
---|
359 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 9
|
---|
360 |
|
---|
361 | Pseudo-states can be chained, in which case a logical AND is
|
---|
362 | implied. For example, the following rule applies to when the
|
---|
363 | mouse hovers over a checked QCheckBox:
|
---|
364 |
|
---|
365 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 10
|
---|
366 |
|
---|
367 | Negated Pseudo-states may appear in Pseudo-state chains. For example,
|
---|
368 | the following rule applies when the mouse hovers over a QPushButton
|
---|
369 | that is not pressed:
|
---|
370 |
|
---|
371 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 11
|
---|
372 |
|
---|
373 | If needed, logical OR can be expressed using the comma operator:
|
---|
374 |
|
---|
375 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 12
|
---|
376 |
|
---|
377 | Pseudo-states can appear in combination with subcontrols. For
|
---|
378 | example:
|
---|
379 |
|
---|
380 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 13
|
---|
381 |
|
---|
382 | See the \l{List of Pseudo-States} section below for the list of
|
---|
383 | pseudo-states provided by Qt widgets.
|
---|
384 |
|
---|
385 | \section1 Conflict Resolution
|
---|
386 |
|
---|
387 | Conflicts arise when several style rules specify the same
|
---|
388 | properties with different values. Consider the following style
|
---|
389 | sheet:
|
---|
390 |
|
---|
391 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 14
|
---|
392 |
|
---|
393 | Both rules match QPushButton instances called \c okButton and
|
---|
394 | there is a conflict for the \c color property. To resolve this
|
---|
395 | conflict, we must take into account the \e specificity of the
|
---|
396 | selectors. In the above example, \c{QPushButton#okButton} is
|
---|
397 | considered more specific than \c QPushButton, because it
|
---|
398 | (usually) refers to a single object, not to all instances of a
|
---|
399 | class.
|
---|
400 |
|
---|
401 | Similarly, selectors with pseudo-states are more specific that
|
---|
402 | ones that do not specify pseudo-states. Thus, the following style
|
---|
403 | sheet specifies that a \l{QPushButton} should have white text
|
---|
404 | when the mouse is hovering over it, otherwise red text:
|
---|
405 |
|
---|
406 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 15
|
---|
407 |
|
---|
408 | Here's a tricky one:
|
---|
409 |
|
---|
410 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 16
|
---|
411 |
|
---|
412 | Here, both selectors have the same specificity, so if the mouse
|
---|
413 | hovers over the button while it is enabled, the second rule takes
|
---|
414 | precedence. If we want the text to be white in that case, we can
|
---|
415 | reorder the rules like this:
|
---|
416 |
|
---|
417 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 17
|
---|
418 |
|
---|
419 | Alternatively, we can make the first rule more specific:
|
---|
420 |
|
---|
421 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 18
|
---|
422 |
|
---|
423 | A similar issue arises in conjunction with Type Selectors.
|
---|
424 | Consider the following example:
|
---|
425 |
|
---|
426 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 19
|
---|
427 |
|
---|
428 | Both rules apply to QPushButton instances (since QPushButton
|
---|
429 | inherits QAbstractButton) and there is a conflict for the
|
---|
430 | \l{Qt Style Sheets Reference#color-prop}{color} property. Because QPushButton
|
---|
431 | inherits QAbstractButton, it might be tempting to assume that
|
---|
432 | \c QPushButton is more specific than \c QAbstractButton. However,
|
---|
433 | for style sheet computations, all Type Selectors have the same
|
---|
434 | specificity, and the rule that appears last takes precedence. In
|
---|
435 | other words, \l{Qt Style Sheets Reference#color-prop}{color} is set to \c gray
|
---|
436 | for all \l{QAbstractButton}s, including \l{QPushButton}s. If we really
|
---|
437 | want \l{QPushButton}s to have red text, we can always reorder the
|
---|
438 | rules.
|
---|
439 |
|
---|
440 | For determining the specificity of a rule, Qt Style Sheets follow
|
---|
441 | the
|
---|
442 | \l{http://www.w3.org/TR/REC-CSS2/cascade.html#specificity}{CSS2
|
---|
443 | Specification}:
|
---|
444 |
|
---|
445 | \quotation
|
---|
446 | \e{A selector's specificity is calculated as follows:}
|
---|
447 |
|
---|
448 | \list
|
---|
449 | \o \e{count the number of ID attributes in the selector (= a)}
|
---|
450 | \o \e{count the number of other attributes and pseudo-classes in the selector (= b)}
|
---|
451 | \o \e{count the number of element names in the selector (= c)}
|
---|
452 | \o \e{ignore pseudo-elements [i.e., \l{subcontrols}].}
|
---|
453 | \endlist
|
---|
454 |
|
---|
455 | \e{Concatenating the three numbers a-b-c (in a number system with a
|
---|
456 | large base) gives the specificity.}
|
---|
457 |
|
---|
458 | \e{Some examples:}
|
---|
459 |
|
---|
460 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 20
|
---|
461 | \endquotation
|
---|
462 |
|
---|
463 | \section1 Cascading
|
---|
464 |
|
---|
465 | Style sheets can be set on the QApplication, on parent widgets,
|
---|
466 | and on child widgets. An arbitrary widget's effective style sheet
|
---|
467 | is obtained by merging the style sheets set on the widget's
|
---|
468 | ancestors (parent, grandparent, etc.), as well as any style sheet
|
---|
469 | set on the QApplication.
|
---|
470 |
|
---|
471 | When conflicts arise, the widget's own style sheet is always
|
---|
472 | preferred to any inherited style sheet, irrespective of the
|
---|
473 | specificity of the conflicting rules. Likewise, the parent
|
---|
474 | widget's style sheet is preferred to the grandparent's, etc.
|
---|
475 |
|
---|
476 | One consequence of this is that setting a style rule on a widget
|
---|
477 | automatically gives it precedence over other rules specified in
|
---|
478 | the ancestor widgets' style sheets or the QApplication style
|
---|
479 | sheet. Consider the following example. First, we set a style
|
---|
480 | sheet on the QApplication:
|
---|
481 |
|
---|
482 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 21
|
---|
483 |
|
---|
484 | Then we set a style sheet on a QPushButton object:
|
---|
485 |
|
---|
486 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 22
|
---|
487 |
|
---|
488 | The style sheet on the QPushButton forces the QPushButton (and
|
---|
489 | any child widget) to have blue text, in spite of the more
|
---|
490 | specific rule set provided by the application-wide style sheet.
|
---|
491 |
|
---|
492 | The result would have been the same if we had written
|
---|
493 |
|
---|
494 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 23
|
---|
495 |
|
---|
496 | except that if the QPushButton had children (which is unlikely),
|
---|
497 | the style sheet would have no impact on them.
|
---|
498 |
|
---|
499 | Style sheet cascading is a complex topic. Refer to the
|
---|
500 | \l{http://www.w3.org/TR/CSS2/cascade.html#cascade}{CSS2
|
---|
501 | Specification} for the gory details. Be aware that Qt currently
|
---|
502 | doesn't implement \c{!important}.
|
---|
503 |
|
---|
504 | \section1 Inheritance
|
---|
505 |
|
---|
506 | In classic CSS, when font and color of an item is not explicitly set,
|
---|
507 | it gets automatically inherited from the parent. When using Qt Style Sheets,
|
---|
508 | a widget does \bold{not} automatically inherit its font and color setting
|
---|
509 | from its parent widget.
|
---|
510 |
|
---|
511 | For example, consider a QPushButton inside a QGroupBox:
|
---|
512 |
|
---|
513 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 24
|
---|
514 |
|
---|
515 | The QPushButton does not have an explicit color set. Hence, instead
|
---|
516 | of inheriting color of its parent QGroupBox, it has the system color.
|
---|
517 | If we want to set the color on a QGroupBox and its children,
|
---|
518 | we can write:
|
---|
519 |
|
---|
520 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 25
|
---|
521 |
|
---|
522 | In contrast, setting a font and propagate using QWidget::setFont() and
|
---|
523 | QWidget::setPalette() propagates to child widgets.
|
---|
524 |
|
---|
525 | \section1 Widgets inside C++ namespaces
|
---|
526 |
|
---|
527 | The Type Selector can be used to style widgets of a particular type. For
|
---|
528 | example,
|
---|
529 |
|
---|
530 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 26
|
---|
531 |
|
---|
532 | Qt Style Sheet uses QObject::className() of the widget to determine
|
---|
533 | when to apply the Type Selector. When custom widgets are inside namespaces,
|
---|
534 | the QObject::className() returns <namespace>::<classname>. This conflicts
|
---|
535 | with the syntax for \l{Sub-Controls}. To overcome this problem,
|
---|
536 | when using the Type Selector for widgets inside namespaces, we must
|
---|
537 | replace the "::" with "--". For example,
|
---|
538 |
|
---|
539 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 27
|
---|
540 |
|
---|
541 | \section1 Setting QObject properties
|
---|
542 |
|
---|
543 | From 4.3 and above, any designable Q_PROPERTY
|
---|
544 | can be set using the qproperty-<property name> syntax.
|
---|
545 |
|
---|
546 | For example,
|
---|
547 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 28
|
---|
548 |
|
---|
549 | If the property references an enum declared with Q_ENUMS, you should
|
---|
550 | reference its constants by name, i.e., not their numeric value.
|
---|
551 |
|
---|
552 | */
|
---|
553 |
|
---|
554 | /*!
|
---|
555 | \page stylesheet-designer.html
|
---|
556 | \contentspage {Qt Style Sheet}{Contents}
|
---|
557 | \previouspage The Style Sheet Syntax
|
---|
558 | \nextpage Customizing Qt Widgets Using Style Sheets
|
---|
559 | \title Qt Designer Integration
|
---|
560 |
|
---|
561 | \l{Qt Designer}{Qt Designer} is an excellent tool
|
---|
562 | to preview style sheets. You can right-click on any widget in Designer
|
---|
563 | and select \gui{Change styleSheet...} to set the style sheet.
|
---|
564 |
|
---|
565 | \image designer-stylesheet-options.png
|
---|
566 |
|
---|
567 | In Qt 4.2 and later, \l{Qt Designer}{Qt Designer} also includes a
|
---|
568 | style sheet syntax highlighter and validator. The validator indicates
|
---|
569 | if the syntax is valid or invalid, at the bottom left of the \gui{Edit
|
---|
570 | Style Sheet} dialog.
|
---|
571 |
|
---|
572 | \image designer-validator-highlighter.png
|
---|
573 |
|
---|
574 | When you click \gui{OK} or \gui{Apply}, \QD will automatically display
|
---|
575 | the widget with its new stylesheet.
|
---|
576 |
|
---|
577 | \image designer-stylesheet-usage.png
|
---|
578 | */
|
---|
579 |
|
---|
580 | /*!
|
---|
581 | \page stylesheet-customizing.html
|
---|
582 | \contentspage {Qt Style Sheet}{Contents}
|
---|
583 | \previouspage Qt Designer Integration
|
---|
584 | \nextpage Qt Style Sheets Reference
|
---|
585 | \title Customizing Qt Widgets Using Style Sheets
|
---|
586 |
|
---|
587 | When using style sheets, every widget is treated as a box with four
|
---|
588 | concentric rectangles: the margin rectangle, the border rectangle, the
|
---|
589 | padding rectangle, and the content rectangle. The box model describes
|
---|
590 | this in further detail.
|
---|
591 |
|
---|
592 | \target box model
|
---|
593 | \section1 The Box Model
|
---|
594 |
|
---|
595 | The four concentric rectangles appear conceptually as below:
|
---|
596 |
|
---|
597 | \image stylesheet-boxmodel.png
|
---|
598 |
|
---|
599 | \list
|
---|
600 | \o The margin falls outside the border.
|
---|
601 | \o The border is drawn between the margin and the padding.
|
---|
602 | \o The padding falls inside the border, between the border and
|
---|
603 | the actual contents.
|
---|
604 | \o The content is what is left from the original widget or
|
---|
605 | subcontrol once we have removed the margin, the border, and
|
---|
606 | the padding.
|
---|
607 | \endlist
|
---|
608 |
|
---|
609 | The \l{Qt Style Sheets Reference#margin-prop}{margin},
|
---|
610 | \l{Qt Style Sheets Reference#border-width-prop}
|
---|
611 | {border-width}, and
|
---|
612 | \l{Qt Style Sheets Reference#padding-prop}{padding}
|
---|
613 | properties all default to zero. In that case, all four rectangles
|
---|
614 | (\c margin, \c border, \c padding, and \c content) coincide exactly.
|
---|
615 |
|
---|
616 | You can specify a background for the widget using the
|
---|
617 | \l{Qt Style Sheets Reference#background-image-prop}{background-image}
|
---|
618 | property. By default, the background-image is drawn only for the area
|
---|
619 | inside the border. This can be changed using the
|
---|
620 | \l{Qt Style Sheets Reference#background-clip-prop}{background-clip}
|
---|
621 | property. You can use
|
---|
622 | \l{Qt Style Sheets Reference#background-repeat-prop}{background-repeat}
|
---|
623 | and
|
---|
624 | \l{Qt Style Sheets Reference#background-origin-prop}{background-origin}
|
---|
625 | to control the repetition and origin of the background image.
|
---|
626 |
|
---|
627 | A background-image does not scale with the size of the widget. To provide
|
---|
628 | a "skin" or background that scales along with the widget size, one must
|
---|
629 | use
|
---|
630 | \l{Qt Style Sheets Reference#border-image-prop}{border-image}. Since the
|
---|
631 | border-image property provides an alternate background, it is not required
|
---|
632 | to specify a background-image when border-image is specified. In the case,
|
---|
633 | when both of them are specified, the border-image draws over the
|
---|
634 | background-image.
|
---|
635 |
|
---|
636 | In addition, the \l{Qt Style Sheets Reference#image-prop}{image} property
|
---|
637 | may be used to draw an image over the border-image. The image specified does
|
---|
638 | not tile or stretch and when its size does not match the size of the widget,
|
---|
639 | its alignment is specified using the
|
---|
640 | \l{Qt Style Sheets Reference#image-position-prop}{image-position}
|
---|
641 | property. Unlike background-image and border-image, one may specify a
|
---|
642 | SVG in the image property, in which case the image is scaled automatically
|
---|
643 | according to the widget size.
|
---|
644 |
|
---|
645 | The steps to render a rule are as follows:
|
---|
646 | \list
|
---|
647 | \o Set clip for entire rendering operation (border-radius)
|
---|
648 | \o Draw the background (background-image)
|
---|
649 | \o Draw the border (border-image, border)
|
---|
650 | \o Draw overlay image (image)
|
---|
651 | \endlist
|
---|
652 |
|
---|
653 | \target sub controls
|
---|
654 | \section1 Sub-controls
|
---|
655 |
|
---|
656 | A widget is considered as a heirarchy (tree) of subcontrols drawn on top
|
---|
657 | of each other. For example, the QComboBox draws the drop-down sub-control
|
---|
658 | followed by the down-arrow sub-control. A QComboBox is thus rendered as
|
---|
659 | follows:
|
---|
660 | \list
|
---|
661 | \o Render the QComboBox { } rule
|
---|
662 | \o Render the QComboBox::drop-down { } rule
|
---|
663 | \o Render the QComboBox::down-arrow { } rule
|
---|
664 | \endlist
|
---|
665 |
|
---|
666 | Sub-controls share a parent-child relationship. In the case of QComboBox,
|
---|
667 | the parent of down-arrow is the drop-down and the parent of drop-down is
|
---|
668 | the widget itself. Sub-controls are positioned within their parent using
|
---|
669 | the \l{Qt Style Sheets Reference#subcontrol-position-prop}
|
---|
670 | {subcontrol-position} and
|
---|
671 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}
|
---|
672 | properties.
|
---|
673 |
|
---|
674 | Once positioned, sub-controls can be styled using the the \l{box model}.
|
---|
675 |
|
---|
676 | \note With complex widgets such as QComboBox and QScrollBar, if one
|
---|
677 | property or sub-control is customized, \bold{all} the other properties or
|
---|
678 | sub-controls must be customized as well.
|
---|
679 |
|
---|
680 | */
|
---|
681 |
|
---|
682 | /*!
|
---|
683 | \page stylesheet-reference.html
|
---|
684 | \contentspage {Qt Style Sheet}{Contents}
|
---|
685 | \previouspage Customizing Qt Widgets Using Style Sheets
|
---|
686 | \nextpage Qt Style Sheets Examples
|
---|
687 | \title Qt Style Sheets Reference
|
---|
688 |
|
---|
689 | Qt Style Sheets support various properties, pseudo-states, and
|
---|
690 | subcontrols that make it possible to customize the look of
|
---|
691 | widgets.
|
---|
692 |
|
---|
693 | \tableofcontents
|
---|
694 |
|
---|
695 | \section1 List of Stylable Widgets
|
---|
696 |
|
---|
697 | The following table lists the Qt widgets that can be customized
|
---|
698 | using style sheets:
|
---|
699 |
|
---|
700 | \table 100%
|
---|
701 | \header
|
---|
702 | \o Widget
|
---|
703 | \o How to Style
|
---|
704 |
|
---|
705 | \row
|
---|
706 | \o QAbstractScrollArea \target qabstractscrollarea-widget
|
---|
707 | \o Supports the \l{box model}.
|
---|
708 |
|
---|
709 | All derivatives of QAbstractScrollArea, including QTextEdit,
|
---|
710 | and QAbstractItemView (all item view classes), support
|
---|
711 | scrollable backgrounds using
|
---|
712 | \l{Qt Style Sheets Reference#background-attachment-prop}
|
---|
713 | {background-attachment}. Setting the background-attachment to
|
---|
714 | \c{fixed} provides a background-image that does not scroll with the
|
---|
715 | viewport. Setting the background-attachment to \c{scroll}, scrolls
|
---|
716 | the background-image when the scroll bars move.
|
---|
717 |
|
---|
718 | See \l{Qt Style Sheets Examples#Customizing QAbstractScrollArea}
|
---|
719 | {Customizing QAbstractScrollArea} for an example.
|
---|
720 |
|
---|
721 | \row
|
---|
722 | \o QCheckBox \target qcheckbox-widget
|
---|
723 | \o Supports the \l{box model}. The check indicator can be
|
---|
724 | styled using the \l{#indicator-sub}{::indicator}
|
---|
725 | subcontrol. By default, the indicator is placed in the Top
|
---|
726 | Left corner of the Contents rectangle of the widget.
|
---|
727 |
|
---|
728 | The \l{#spacing-prop}{spacing} property
|
---|
729 | specifies the spacing between the check indicator and
|
---|
730 | the text.
|
---|
731 |
|
---|
732 | See \l{Qt Style Sheets Examples#Customizing QCheckBox}
|
---|
733 | {Customizing QCheckBox} for an example.
|
---|
734 |
|
---|
735 | \row
|
---|
736 | \o QColumnView \target qcolumnview-widget
|
---|
737 | \o The grip can be styled be using the \l{image-prop}{image} property.
|
---|
738 | The arrow indicators can by styled using the
|
---|
739 | \l{left-arrow-sub}{::left-arrow} subcontrol and the
|
---|
740 | \l{right-arrow-sub}{::right-arrow} subcontrol.
|
---|
741 |
|
---|
742 | \row
|
---|
743 | \o QComboBox \target qcombobox-widget
|
---|
744 | \o The frame around the combobox can be styled using the
|
---|
745 | \l{box model}. The drop-down button can be styled using
|
---|
746 | the \l{#drop-down-sub}{::drop-down} subcontrol. By default, the
|
---|
747 | drop-down button is placed in the top right corner of the padding
|
---|
748 | rectangle of the widget. The arrow mark inside the drop-down button
|
---|
749 | can be styled using the \l{#down-arrow-sub}{::down-arrow}
|
---|
750 | subcontrol. By default, the arrow is placed in the center of the
|
---|
751 | contents rectangle of the drop-down subcontrol.
|
---|
752 |
|
---|
753 | See \l{Qt Style Sheets Examples#Customizing QComboBox}{Customizing QComboBox}
|
---|
754 | for an example.
|
---|
755 |
|
---|
756 | \row
|
---|
757 | \o QDateEdit \target qdateedit-widget
|
---|
758 | \o See \l{#qspinbox-widget}{QSpinBox}.
|
---|
759 |
|
---|
760 | \row
|
---|
761 | \o QDateTimeEdit \target qdatetimeedit-widget
|
---|
762 | \o See \l{#qspinbox-widget}{QSpinBox}.
|
---|
763 |
|
---|
764 | \row
|
---|
765 | \o QDialog \target qdialog-widget
|
---|
766 | \o Supports only the \l{Qt Style Sheets Reference#background-prop}{background},
|
---|
767 | \l{#background-clip-prop}{background-clip} and
|
---|
768 | \l{#background-origin-prop}{background-origin} properties.
|
---|
769 |
|
---|
770 | \warning Make sure you define the Q_OBJECT macro for your custom
|
---|
771 | widget.
|
---|
772 |
|
---|
773 | \row
|
---|
774 | \o QDialogButtonBox \target qdialogbuttonbox-widget
|
---|
775 | \o The layout of buttons can be altered using the
|
---|
776 | \l{#button-layout-prop}{button-layout} property.
|
---|
777 |
|
---|
778 | \row
|
---|
779 | \o QDockWidget \target qdockwidget-widget
|
---|
780 | \o Supports styling of the title bar and the title bar buttons when docked.
|
---|
781 |
|
---|
782 | The dock widget border can be styled using the \l{#border-prop}{border}
|
---|
783 | property. The \l{#title-sub}{::title} subcontrol can be used to customize
|
---|
784 | the title bar. The close and float buttons are positioned with respect
|
---|
785 | to the \l{title-sub}{::title} subcontrol using the
|
---|
786 | \l{#close-button-sub}{::close-button} and
|
---|
787 | \l{#float-button-sub}{::float-button} respectively.
|
---|
788 |
|
---|
789 | When the title bar is vertical, the \l{#vertical-ps}{:vertical} pseudo
|
---|
790 | class is set. In addition, depending on QDockWidget::DockWidgetFeature,
|
---|
791 | the \l{#closable-ps}{:closable}, \l{#floatable-ps}{:floatable} and
|
---|
792 | \l{#movable-ps}{:movable} pseudo states are set.
|
---|
793 |
|
---|
794 | \note Use QMainWindow::separator to style the resize handle.
|
---|
795 |
|
---|
796 | \warning The style sheet has no effect when the QDockWidget is undocked
|
---|
797 | as Qt uses native top level windows when undocked.
|
---|
798 |
|
---|
799 | See \l{Qt Style Sheets Examples#Customizing QDockWidget}
|
---|
800 | {Customizing QDockWidget} for an example.
|
---|
801 |
|
---|
802 | \row
|
---|
803 | \o QDoubleSpinBox \target qdoublespinbox-widget
|
---|
804 | \o See \l{#qspinbox-widget}{QSpinBox}.
|
---|
805 |
|
---|
806 | \row
|
---|
807 | \o QFrame \target qframe-widget
|
---|
808 | \o Supports the \l{box model}.
|
---|
809 |
|
---|
810 | Since 4.3, setting a stylesheet on a QLabel automatically
|
---|
811 | sets the QFrame::frameStyle property to QFrame::StyledPanel.
|
---|
812 |
|
---|
813 | See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame}
|
---|
814 | for an example.
|
---|
815 |
|
---|
816 | \row
|
---|
817 | \o QGroupBox \target qgroupbox-widget
|
---|
818 | \o Supports the \l{box model}. The title can be styled using the
|
---|
819 | \l{#title-sub}{::title} subcontrol. By default, the title is placed
|
---|
820 | depending on QGroupBox::textAlignment.
|
---|
821 |
|
---|
822 | In the case of a checkable QGroupBox, the title includes the
|
---|
823 | check indicator. The indicator is styled using the
|
---|
824 | the \l{#indicator-sub}{::indicator} subcontrol. The
|
---|
825 | \l{#spacing-prop}{spacing} property can be used to control
|
---|
826 | the spacing between the text and indicator.
|
---|
827 |
|
---|
828 | See \l{Qt Style Sheets Examples#Customizing QGroupBox}{Customizing QGroupBox}
|
---|
829 | for an example.
|
---|
830 |
|
---|
831 | \row
|
---|
832 | \o QHeaderView \target qheaderview-widget
|
---|
833 | \o Supports the \l{box model}. The sections of the header view are
|
---|
834 | styled using the \l{#section-sub}{::section} sub control. The
|
---|
835 | \c{section} Sub-control supports the \l{#middle-ps}{:middle},
|
---|
836 | \l{#first-ps}{:first}, \l{#last-ps}{:last},
|
---|
837 | \l{#only-one-ps}{:only-one}, \l{#next-selected-ps}{:next-selected},
|
---|
838 | \l{#previous-selected-ps}{:previous-selected},
|
---|
839 | \l{#selected-ps}{:selected} pseudo states.
|
---|
840 |
|
---|
841 | Sort indicator in can be styled using the
|
---|
842 | \l{#up-arrow-sub}{::up-arrow} and the
|
---|
843 | \l{#down-arrow-sub}{::down-arrow} Sub-control.
|
---|
844 |
|
---|
845 | See \l{Qt Style Sheets Examples#Customizing QHeaderView}{Customizing QHeaderView}
|
---|
846 | for an example.
|
---|
847 |
|
---|
848 | \row
|
---|
849 | \o QLabel \target qlabel-widget
|
---|
850 | \o Supports the \l{box model}. Does not support the
|
---|
851 | \l{#hover-ps}{:hover} pseudo-state.
|
---|
852 |
|
---|
853 | Since 4.3, setting a stylesheet on a QLabel automatically
|
---|
854 | sets the QFrame::frameStyle property to QFrame::StyledPanel.
|
---|
855 |
|
---|
856 | See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame} for an
|
---|
857 | example (a QLabel derives from QFrame).
|
---|
858 |
|
---|
859 | \row
|
---|
860 | \o QLineEdit \target qlineedit-widget
|
---|
861 | \o Support the \l{box model}.
|
---|
862 |
|
---|
863 | The color and background of the selected item is styled using
|
---|
864 | \l{#selection-color-prop}{selection-color} and
|
---|
865 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
866 | respectively.
|
---|
867 |
|
---|
868 | The password character can be styled using the
|
---|
869 | \l{#lineedit-password-character-prop}{lineedit-password-character}
|
---|
870 | property.
|
---|
871 |
|
---|
872 | See \l{Qt Style Sheets Examples#Customizing QLineEdit}{Customizing QLineEdit}
|
---|
873 | for an example.
|
---|
874 |
|
---|
875 | \row
|
---|
876 | \o QListView \target qlistview-widget
|
---|
877 | \o Supports the \l{box model}. When
|
---|
878 | \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
|
---|
879 | is enabled, the alternating colors can be styled using the
|
---|
880 | \l{#alternate-background-color-prop}{alternate-background-color}
|
---|
881 | property.
|
---|
882 |
|
---|
883 | The color and background of the selected item is styled using
|
---|
884 | \l{#selection-color-prop}{selection-color} and
|
---|
885 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
886 | respectively.
|
---|
887 |
|
---|
888 | The selection behavior is controlled by the
|
---|
889 | \l{#show-decoration-selected-prop}{show-decoration-selected} property.
|
---|
890 |
|
---|
891 | Use the \l{#item-sub}{::item} subcontrol for more fine grained
|
---|
892 | control over the items in the QListView.
|
---|
893 |
|
---|
894 | See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
|
---|
895 | style scrollable backgrounds.
|
---|
896 |
|
---|
897 | See \l{Qt Style Sheets Examples#Customizing QListView}
|
---|
898 | {Customzing QListView} for an example.
|
---|
899 |
|
---|
900 | \row
|
---|
901 | \o QListWidget \target qlistwidget-widget
|
---|
902 | \o See \l{#qlistview-widget}{QListView}.
|
---|
903 |
|
---|
904 | \row
|
---|
905 | \o QMainWindow \target qmainwindow-widget
|
---|
906 | \o Supports styling of the separator
|
---|
907 |
|
---|
908 | The separator in a QMainWindow when using QDockWidget is styled
|
---|
909 | using the \l{#separator-sub}{::separator} subcontrol.
|
---|
910 |
|
---|
911 | See \l{Qt Style Sheets Examples#Customizing QMainWindow}{Customizing QMainWindow}
|
---|
912 | for an example.
|
---|
913 |
|
---|
914 | \row
|
---|
915 | \o QMenu \target qmenu-widget
|
---|
916 | \o Supports the \l{box model}.
|
---|
917 |
|
---|
918 | Individual items are styled using the \l{#item-sub}{::item}
|
---|
919 | subcontrol. In addition to the usually supported pseudo states,
|
---|
920 | \c{item} subcontrol supports the
|
---|
921 | \l{#selected-ps}{:selected}, \l{#default-ps}{:default},
|
---|
922 | \l{#exclusive-ps}{:exclusive} and the
|
---|
923 | \l{#non-exclusive-ps}{non-exclusive} pseudo states.
|
---|
924 |
|
---|
925 | The indicator of checkable menu items is styled using the
|
---|
926 | \l{#indicator-sub}{::indicator} subcontrol.
|
---|
927 |
|
---|
928 | The separator is styled using the \l{#separator-sub}{::separator}
|
---|
929 | subcontrol.
|
---|
930 |
|
---|
931 | For items with a sub menu, the arrow marks are styled using the
|
---|
932 | \l{::right-arrow-sub}{right-arrow} and
|
---|
933 | \l{::left-arrow-sub}{left-arrow}.
|
---|
934 |
|
---|
935 | The scroller is styled using the \l{#scroller-sub}{::scroller}.
|
---|
936 |
|
---|
937 | The tear-off is styled using the \l{#tear-off-sub}{::tear-off}.
|
---|
938 |
|
---|
939 | See \l{Qt Style Sheets Examples#Customizing QMenu}{Customizing QMenu}
|
---|
940 | for an example.
|
---|
941 |
|
---|
942 | \row
|
---|
943 | \o QMenuBar \target qmenubar-widget
|
---|
944 | \o Supports the \l{box model}. The \l{#spacing-prop}{spacing}
|
---|
945 | property specifies the spacing between menu items.
|
---|
946 | Individual items are styled using the \l{#item-sub}{::item}
|
---|
947 | subcontrol.
|
---|
948 |
|
---|
949 | \warning When running on Qt/Mac, the menu bar is usually embedded into the
|
---|
950 | system-wide menu bar. In this case, the style sheet will have no effect.
|
---|
951 |
|
---|
952 | See \l{Qt Style Sheets Examples#Customizing QMenuBar}{Customizing QMenuBar}
|
---|
953 | for an example.
|
---|
954 |
|
---|
955 | \row
|
---|
956 | \o QMessageBox \target qmessagebox-widget
|
---|
957 | \o The \l{#messagebox-text-interaction-flags-prop}
|
---|
958 | {messagebox-text-interaction-flags} property can be used to alter
|
---|
959 | the interaction with text in the message box.
|
---|
960 |
|
---|
961 | \row
|
---|
962 | \o QProgressBar \target qprogressbar-widget
|
---|
963 | \o Supports the \l{box model}. The chunks of the progress bar
|
---|
964 | can be styled using the \l{#chunk-sub}{::chunk} subcontrol.
|
---|
965 | The chunk is displayed on the Contents rectangle of the widget.
|
---|
966 |
|
---|
967 | If the progress bar displays text, use the \l{text-align-prop}{text-align}
|
---|
968 | property to position the text.
|
---|
969 |
|
---|
970 | Indeterminate progress bars have the
|
---|
971 | \l{#indeterminate-ps}{:indeterminate} pseudo state set.
|
---|
972 |
|
---|
973 | See \l{Qt Style Sheets Examples#Customizing QProgressBar}{Customizing QProgressBar}
|
---|
974 | for an example.
|
---|
975 |
|
---|
976 | \row
|
---|
977 | \o QPushButton \target qpushbutton-widget
|
---|
978 | \o Supports the \l{box model}. Supports the \l{#default-ps}{:default},
|
---|
979 | \l{#flat-ps}{:flat}, \l{#checked-ps}{:checked} pseudo states.
|
---|
980 |
|
---|
981 | For QPushButton with a menu, the menu indicator is styled
|
---|
982 | using the \l{#menu-indicator-sub}{::menu-indicator}
|
---|
983 | subcontrol. Appearance of checkable push buttons can be
|
---|
984 | customized using the \l{#open-ps}{:open} and
|
---|
985 | \l{#closed-ps}{:closed} pseudo-states.
|
---|
986 |
|
---|
987 | \warning If you only set a background-color on a QPushButton, the background
|
---|
988 | may not appear unless you set the border property to some value. This is
|
---|
989 | because, by default, the QPushButton draws a native border which completely
|
---|
990 | overlaps the background-color. For example,
|
---|
991 |
|
---|
992 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 30
|
---|
993 |
|
---|
994 | See \l{Qt Style Sheets Examples#Customizing QPushButton}{Customizing QPushButton}
|
---|
995 | for an example.
|
---|
996 |
|
---|
997 | \row
|
---|
998 | \o QRadioButton \target qradiobutton-widget
|
---|
999 | \o Supports the \l{box model}. The check indicator can be
|
---|
1000 | styled using the \l{#indicator-sub}{::indicator}
|
---|
1001 | subcontrol. By default, the indicator is placed in the Top
|
---|
1002 | Left corner of the Contents rectangle of the widget.
|
---|
1003 |
|
---|
1004 | The \l{#spacing-prop}{spacing} property
|
---|
1005 | specifies the spacing between the check indicator and
|
---|
1006 | the text.
|
---|
1007 |
|
---|
1008 | See \l{Qt Style Sheets Examples#Customizing QRadioButton}
|
---|
1009 | {Customizing QRadioButton} for an example.
|
---|
1010 |
|
---|
1011 | \row
|
---|
1012 | \o QScrollBar \target qscrollbar-widget
|
---|
1013 | \o Supports the \l{box model}. The Contents rectangle of the widget
|
---|
1014 | is considered to be the groove over which the slider moves. The extent
|
---|
1015 | of the QScrollBar (i.e the width or the height depending on the orientation)
|
---|
1016 | is set using the \l{#width-prop}{width} or \l{#height-prop}{height} property
|
---|
1017 | respectively. To determine the orientation, use the
|
---|
1018 | \l{#horizontal-ps}{:horizontal} and the \l{vertical-ps}{:vertical}
|
---|
1019 | pseudo states.
|
---|
1020 |
|
---|
1021 | The slider can be styled using the \l{#handle-sub}{::handle} subcontrol.
|
---|
1022 | Setting the \l{#min-width-prop}{min-width} or \l{#min-height-prop}{min-height}
|
---|
1023 | provides size contraints for the slider depending on the orientation.
|
---|
1024 |
|
---|
1025 | The \l{add-line-sub}{::add-line} subcontrol can be used to style the
|
---|
1026 | button to add a line. By default, the add-line subcontrol is placed in
|
---|
1027 | top right corner of the Border rectangle of the widget. Depending on the
|
---|
1028 | orientation the \l{#right-arrow-sub}{::right-arrow} or
|
---|
1029 | \l{#down-arrow-sub}{::down-arrow}. By default, the arrows are placed in
|
---|
1030 | the center of the Contents rectangle of the add-line subcontrol.
|
---|
1031 |
|
---|
1032 | The \l{sub-line-sub}{::sub-line} subcontrol can be used to style the
|
---|
1033 | button to subtract a line. By default, the sub-line subcontrol is placed in
|
---|
1034 | bottom right corner of the Border rectangle of the widget. Depending on the
|
---|
1035 | orientation the \l{#left-arrow-sub}{::left-arrow} or
|
---|
1036 | \l{#up-arrow-sub}{::up-arrow}. By default, the arrows are placed in
|
---|
1037 | the center of the Contents rectangle of the sub-line subcontrol.
|
---|
1038 |
|
---|
1039 | The \l{sub-page-sub}{::sub-page} subcontrol can be used to style the
|
---|
1040 | region of the slider that subtracts a page. The \l{add-page-sub}{::add-page}
|
---|
1041 | subcontrol can be used to style the region of the slider that adds a page.
|
---|
1042 |
|
---|
1043 | See \l{Qt Style Sheets Examples#Customizing QScrollBar}{Customizing QScrollBar}
|
---|
1044 | for an example.
|
---|
1045 |
|
---|
1046 | \row
|
---|
1047 | \o QSizeGrip \target qsizegrip-widget
|
---|
1048 | \o Supports the \l{#width-prop}{width},
|
---|
1049 | \l{#height-prop}{height}, and \l{#image-prop}{image}
|
---|
1050 | properties.
|
---|
1051 |
|
---|
1052 | See \l{Qt Style Sheets Examples#Customizing QSizeGrip}{Customizing QSizeGrip}
|
---|
1053 | for an example.
|
---|
1054 |
|
---|
1055 | \row
|
---|
1056 | \o QSlider \target qslider-widget
|
---|
1057 | \o Supports the \l{box model}. For horizontal slides, the
|
---|
1058 | \l{min-width-prop}{min-width} and \l{height-prop}{height}
|
---|
1059 | properties must be provided. For vertical sliders, the
|
---|
1060 | \l{min-height-prop}{min-height} and \l{width-prop}{width}
|
---|
1061 | properties must be provided.
|
---|
1062 |
|
---|
1063 | The groove of the slider is styled
|
---|
1064 | using the \l{#groove-sub}{::groove}. The groove is
|
---|
1065 | positioned by default in the Contents rectangle of the widget.
|
---|
1066 | The thumb of the slider is styled using \l{#handle-sub}{::handle}
|
---|
1067 | subcontrol. The subcontrol moves in the Contents rectangle of
|
---|
1068 | the groove subcontrol.
|
---|
1069 |
|
---|
1070 | See \l{Qt Style Sheets Examples#Customizing QSlider}{Customizing QSlider}
|
---|
1071 | for an example.
|
---|
1072 |
|
---|
1073 | \row
|
---|
1074 | \o QSpinBox \target qspinbox-widget
|
---|
1075 | \o The frame of the spin box can be styled using the \l{box
|
---|
1076 | model}.
|
---|
1077 |
|
---|
1078 | The up button and arrow can be styled using the
|
---|
1079 | \l{#up-button-sub}{::up-button} and
|
---|
1080 | \l{#up-arrow-sub}{::up-arrow} subcontrols. By default,
|
---|
1081 | the up-button is placed in the top right corner in the
|
---|
1082 | Padding rectangle of the widget. Without an explicit size,
|
---|
1083 | it occupies half the height of its reference rectangle.
|
---|
1084 | The up-arrow is placed in the center of the Contents
|
---|
1085 | rectangle of the up-button.
|
---|
1086 |
|
---|
1087 | The down button and arrow can be styled using the
|
---|
1088 | \l{#down-button-sub}{::down-button} and
|
---|
1089 | \l{#down-arrow-sub}{::down-arrow} subcontrols. By default,
|
---|
1090 | the down-button is placed in the bottom right corner in the
|
---|
1091 | Padding rectangle of the widget. Without an explicit size,
|
---|
1092 | it occupies half the height of its reference rectangle.
|
---|
1093 | The bottom-arrow is placed in the center of the Contents
|
---|
1094 | rectangle of the bottom-button.
|
---|
1095 |
|
---|
1096 | See \l{Qt Style Sheets Examples#Customizing QSpinBox}{Customizing QSpinBox}
|
---|
1097 | for an example.
|
---|
1098 |
|
---|
1099 | \row
|
---|
1100 | \o QSplitter \target qsplitter-widget
|
---|
1101 | \o Supports the \l{box model}. The handle of the splitter
|
---|
1102 | is styled using the \l{#handle-sub}{::handle} subcontrol.
|
---|
1103 |
|
---|
1104 | See \l{Qt Style Sheets Examples#Customizing QSplitter}{Customizing QSplitter}
|
---|
1105 | for an example.
|
---|
1106 |
|
---|
1107 | \row
|
---|
1108 | \o QStatusBar \target qstatusbar-widget
|
---|
1109 | \o Supports only the \l{Qt Style Sheets Reference#background-prop}
|
---|
1110 | {background} property.
|
---|
1111 | The frame for individual items can be style using the
|
---|
1112 | \l{#item-sub}{::item} subcontrol.
|
---|
1113 |
|
---|
1114 | See \l{Qt Style Sheets Examples#Customizing QStatusBar}{Customizing QStatusBar}
|
---|
1115 | for an example.
|
---|
1116 |
|
---|
1117 | \row
|
---|
1118 | \o QTabBar \target qtabbar-widget
|
---|
1119 | \o Individual tabs may be styled using the \l{#tab-sub}{::tab}
|
---|
1120 | subcontrol. The tabs support the
|
---|
1121 | \l{#only-one-ps}{:only-one}, \l{#first-ps}{:first},
|
---|
1122 | \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
|
---|
1123 | \l{#previous-selected-ps}{:previous--selected},
|
---|
1124 | \l{#next-selected-ps}{:next-selected},
|
---|
1125 | \l{#selected-ps}{:selected} pseudo states.
|
---|
1126 |
|
---|
1127 | The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
|
---|
1128 | \l{#bottom-ps}{:bottom} pseudo states depending on the orientation
|
---|
1129 | of the tabs.
|
---|
1130 |
|
---|
1131 | Overlapping tabs for the selected state are created by using
|
---|
1132 | negative margins or using the \c{absolute} position scheme.
|
---|
1133 |
|
---|
1134 | The tear indicator of the QTabBar is styled using the
|
---|
1135 | \l{#tear-sub}{::tear} subcontrol.
|
---|
1136 |
|
---|
1137 | QTabBar used two QToolButtons for its scrollers that can be styled
|
---|
1138 | using the \c{QTabBar QToolButton} selector. To specify the width
|
---|
1139 | of the scroll button use the \l{#scroller-sub}{::scroller}
|
---|
1140 | subcontrol.
|
---|
1141 |
|
---|
1142 | The alignment of the tabs within the QTabBar is styled
|
---|
1143 | using the \l{#Alignment}{alignment} property. \warning
|
---|
1144 |
|
---|
1145 | To change the position of the QTabBar within a QTabWidget, use the
|
---|
1146 | \l{#tab-bar-sub}{tab-bar} subcontrol (and set subcontrol-position).
|
---|
1147 |
|
---|
1148 | See \l{Qt Style Sheets Examples#Customizing QTabWidget and QTabBar}{Customizing QTabBar}
|
---|
1149 | for an example.
|
---|
1150 |
|
---|
1151 | \row
|
---|
1152 | \o QTabWidget \target qtabwidget-widget
|
---|
1153 | \o The frame of the tab widget is styled using the
|
---|
1154 | \l{#pane-sub}{::pane} subcontrol. The left and right
|
---|
1155 | corners are styled using the \l{#left-corner-sub}{::left-corner}
|
---|
1156 | and \l{#right-corner-sub}{::right-corner} respectively.
|
---|
1157 | The position of the the tab bar is controlled using the
|
---|
1158 | \l{#tab-bar-sub}{::tab-bar} subcontrol.
|
---|
1159 |
|
---|
1160 | By default, the subcontrols have positions of a QTabWidget in
|
---|
1161 | the QWindowsStyle. To place the QTabBar in the center, set the
|
---|
1162 | subcontrol-position of the tab-bar subcontrol.
|
---|
1163 |
|
---|
1164 | The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
|
---|
1165 | \l{#bottom-ps}{:bottom} pseudo states depending on the orientation
|
---|
1166 | of the tabs.
|
---|
1167 |
|
---|
1168 | See \l{Qt Style Sheets Examples#Customizing QTabWidget and QTabBar}
|
---|
1169 | {Customizing QTabWidget} for an example.
|
---|
1170 |
|
---|
1171 | \row
|
---|
1172 | \o QTableView \target qtableview-widget
|
---|
1173 | \o Supports the \l{box model}. When
|
---|
1174 | \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
|
---|
1175 | is enabled, the alternating colors can be styled using the
|
---|
1176 | \l{#alternate-background-color-prop}{alternate-background-color}
|
---|
1177 | property.
|
---|
1178 |
|
---|
1179 | The color and background of the selected item is styled using
|
---|
1180 | \l{#selection-color-prop}{selection-color} and
|
---|
1181 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
1182 | respectively.
|
---|
1183 |
|
---|
1184 | The corner widget in a QTableView is implemented as a QAbstractButton
|
---|
1185 | and can be styled using the "QTableView QTableCornerButton::section"
|
---|
1186 | selector.
|
---|
1187 |
|
---|
1188 | \warning If you only set a background-color on a QTableCornerButton,
|
---|
1189 | the background may not appear unless you set the border property to
|
---|
1190 | some value. This is because, by default, the QTableCornerButton draws a
|
---|
1191 | native border which completely overlaps the background-color.
|
---|
1192 |
|
---|
1193 | The color of the grid can be specified using the
|
---|
1194 | \l{#gridline-color-prop}{gridline-color} property.
|
---|
1195 |
|
---|
1196 | See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
|
---|
1197 | style scrollable backgrounds.
|
---|
1198 |
|
---|
1199 | See \l{Qt Style Sheets Examples#Customizing QTableView}
|
---|
1200 | {Customzing QTableView} for an example.
|
---|
1201 |
|
---|
1202 | \row
|
---|
1203 | \o QTableWidget \target qtablewidget-widget
|
---|
1204 | \o See \l{#qtableview-widget}{QTableView}.
|
---|
1205 |
|
---|
1206 | \row
|
---|
1207 | \o QTextEdit \target qtextedit-widget
|
---|
1208 | \o Supports the \l{box model}.
|
---|
1209 |
|
---|
1210 | The color and background of selected text is styled using
|
---|
1211 | \l{#selection-color-prop}{selection-color} and
|
---|
1212 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
1213 | respectively.
|
---|
1214 |
|
---|
1215 | See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
|
---|
1216 | style scrollable backgrounds.
|
---|
1217 |
|
---|
1218 | \row
|
---|
1219 | \o QTimeEdit \target qtimeedit-widget
|
---|
1220 | \o See \l{#qspinbox-widget}{QSpinBox}.
|
---|
1221 |
|
---|
1222 | \row
|
---|
1223 | \o QToolBar \target qtoolbar-widget
|
---|
1224 | \o Supports the \l{box model}.
|
---|
1225 |
|
---|
1226 | The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
|
---|
1227 | \l{#bottom-ps}{:bottom} pseudo states depending on the area in
|
---|
1228 | which the tool bar is grouped.
|
---|
1229 |
|
---|
1230 | The \l{#first-ps}{:first}, \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
|
---|
1231 | \l{#only-one-ps}{:only-one} pseudo states indicator the position
|
---|
1232 | of the tool bar within a line group (See
|
---|
1233 | QStyleOptionToolBar::positionWithinLine).
|
---|
1234 |
|
---|
1235 | The separator of a QToolBar is styled using the
|
---|
1236 | \l{#separator-sub}{::separator} subcontrol.
|
---|
1237 |
|
---|
1238 | The handle (to move the toolbar) is styled using the
|
---|
1239 | \l{#handle-sub}{::handle} subcontrol.
|
---|
1240 |
|
---|
1241 | See \l{Qt Style Sheets Examples#Customizing QToolBar}{Customizing QToolBar}
|
---|
1242 | for an example.
|
---|
1243 |
|
---|
1244 | \row
|
---|
1245 | \o QToolButton \target qtoolbutton-widget
|
---|
1246 | \o Supports the \l{box model}.
|
---|
1247 |
|
---|
1248 | If the QToolButton has a menu, is
|
---|
1249 | \l{#menu-indicator-sub}{::menu-indicator} subcontrol can be used to
|
---|
1250 | style the indicator. By default, the menu-indicator is positioned
|
---|
1251 | at the bottom right of the Padding rectangle of the widget.
|
---|
1252 |
|
---|
1253 | If the QToolButton is in QToolButton::MenuButtonPopup mode,
|
---|
1254 | the \l{#menu-button-sub}{::menu-button} subcontrol is used to draw the
|
---|
1255 | menu button. \l{#menu-arrow-sub}{::menu-arrow} subcontrol is used to
|
---|
1256 | draw the menu arrow inside the menu-button. By default, it is
|
---|
1257 | positioned in the center of the Contents rectangle of the the
|
---|
1258 | menu-button subcontrol.
|
---|
1259 |
|
---|
1260 | When the QToolButton displays arrows, the \l{#up-arrow-sub}{::up-arrow},
|
---|
1261 | \l{#down-arrow-sub}{::down-arrow}, \l{#left-arrow-sub}{::left-arrow}
|
---|
1262 | and \l{#right-arrow-sub}{::right-arrow} subcontrols are used.
|
---|
1263 |
|
---|
1264 | \warning If you only set a background-color on a QToolButton, the background
|
---|
1265 | will not appear unless you set the border property to some value. This is
|
---|
1266 | because, by default, the QToolButton draws a native border which completely
|
---|
1267 | overlaps the background-color. For example,
|
---|
1268 |
|
---|
1269 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 31
|
---|
1270 |
|
---|
1271 | See \l{Qt Style Sheets Examples#Customizing QToolButton}{Customizing QToolButton}
|
---|
1272 | for an example.
|
---|
1273 |
|
---|
1274 | \row
|
---|
1275 | \o QToolBox \target qtoolbox-widget
|
---|
1276 | \o Supports the \l{box model}.
|
---|
1277 |
|
---|
1278 | The individual tabs can by styled using the
|
---|
1279 | \l{#tab-sub}{::tab} subcontrol. The tabs support the
|
---|
1280 | \l{#only-one-ps}{:only-one}, \l{#first-ps}{:first},
|
---|
1281 | \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
|
---|
1282 | \l{#previous-selected-ps}{:previous-selected},
|
---|
1283 | \l{#next-selected-ps}{:next-selected},
|
---|
1284 | \l{#selected-ps}{:selected} pseudo states.
|
---|
1285 |
|
---|
1286 | \row
|
---|
1287 | \o QToolTip \target qtooltip-widget
|
---|
1288 | \o Supports the \l{box model}. The \l{#opacity-prop}{opacity}
|
---|
1289 | property controls the opacity of the tooltip.
|
---|
1290 |
|
---|
1291 | See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame}
|
---|
1292 | for an example (a QToolTip is a QFrame).
|
---|
1293 |
|
---|
1294 | \row
|
---|
1295 | \o QTreeView \target qtreeview-widget
|
---|
1296 | \o Supports the \l{box model}. When
|
---|
1297 | \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
|
---|
1298 | is enabled, the alternating colors can be styled using the
|
---|
1299 | \l{#alternate-background-color-prop}{alternate-background-color}
|
---|
1300 | property.
|
---|
1301 |
|
---|
1302 | The color and background of the selected item is styled using
|
---|
1303 | \l{#selection-color-prop}{selection-color} and
|
---|
1304 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
1305 | respectively.
|
---|
1306 |
|
---|
1307 | The selection behavior is controlled by the
|
---|
1308 | \l{#show-decoration-selected-prop}{show-decoration-selected} property.
|
---|
1309 |
|
---|
1310 | The branches of the tree view can be styled using the
|
---|
1311 | \l{#branch-sub}{::branch} subcontrol. The
|
---|
1312 | ::branch Sub-control supports the \l{open-ps}{:open},
|
---|
1313 | \l{closed-ps}{:closed}, \l{has-siblings-ps}{:has-sibling} and
|
---|
1314 | \l{has-children-ps}{:has-children} pseudo states.
|
---|
1315 |
|
---|
1316 | Use the \l{#item-sub}{::item} subcontrol for more fine grained
|
---|
1317 | control over the items in the QTreeView.
|
---|
1318 |
|
---|
1319 | See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
|
---|
1320 | style scrollable backgrounds.
|
---|
1321 |
|
---|
1322 | See \l{Qt Style Sheets Examples#Customizing QTreeView}{Customizing QTreeView}
|
---|
1323 | for an example to style the branches.
|
---|
1324 |
|
---|
1325 | \row
|
---|
1326 | \o QTreeWidget \target qtreewidget-widget
|
---|
1327 | \o See \l{#qtreeview-widget}{QTreeView}.
|
---|
1328 |
|
---|
1329 | \row
|
---|
1330 | \o QWidget \target qwidget-widget
|
---|
1331 | \o Supports only the \l{Qt Style Sheets Reference#background-prop}{background},
|
---|
1332 | \l{#background-clip-prop}{background-clip} and
|
---|
1333 | \l{#background-origin-prop}{background-origin} properties.
|
---|
1334 |
|
---|
1335 | If you subclass from QWidget, you need to provide a paintEvent for your
|
---|
1336 | custom QWidget as below:
|
---|
1337 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 32
|
---|
1338 |
|
---|
1339 | The above code is a no-operation if there is no stylesheet set.
|
---|
1340 |
|
---|
1341 | \warning Make sure you define the Q_OBJECT macro for your custom
|
---|
1342 | widget.
|
---|
1343 |
|
---|
1344 | \endtable
|
---|
1345 |
|
---|
1346 | \section1 List of Properties
|
---|
1347 |
|
---|
1348 | The table below lists all the properties supported by Qt Style
|
---|
1349 | Sheets. Which values can be given to an property depend on the
|
---|
1350 | \l{List of Property Types}{property's type}. Unless otherwise
|
---|
1351 | specified, properties below apply to all widgets. Properties
|
---|
1352 | marked with an asterisk * are specific to Qt and have no equivalent
|
---|
1353 | in CSS2 or CSS3.
|
---|
1354 |
|
---|
1355 | \table 100%
|
---|
1356 | \header
|
---|
1357 | \o Property
|
---|
1358 | \o Type
|
---|
1359 | \o Description
|
---|
1360 |
|
---|
1361 | \row
|
---|
1362 | \o \bold{\c alternate-background-color} \target alternate-background-color-prop
|
---|
1363 | \o \l{#Brush}{Brush} \BR
|
---|
1364 | \o The \l{QAbstractItemView::alternatingRowColors}
|
---|
1365 | {alternate background color} used in QAbstractItemView subclasses.
|
---|
1366 |
|
---|
1367 | If this property is not set, the default value is
|
---|
1368 | whatever is set for the palette's
|
---|
1369 | \l{QPalette::}{AlternateBase} role.
|
---|
1370 |
|
---|
1371 | Example:
|
---|
1372 |
|
---|
1373 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 33
|
---|
1374 |
|
---|
1375 | See also \l{Qt Style Sheets Reference#background-prop}{background} and
|
---|
1376 | \l{#selection-background-color-prop}{selection-background-color}.
|
---|
1377 |
|
---|
1378 | \row
|
---|
1379 | \o \bold{\c background} \target background-prop
|
---|
1380 | \o \l{#Background}{Background}
|
---|
1381 | \o Shorthand notation for setting the background. Equivalent
|
---|
1382 | to specifying \c background-color, \c background-image, \c
|
---|
1383 | background-repeat, and/or \c background-position.
|
---|
1384 |
|
---|
1385 | This property is supported by QAbstractItemView
|
---|
1386 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1387 | QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit,
|
---|
1388 | QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
|
---|
1389 | QTextEdit, QToolTip, and plain \l{QWidget}s.
|
---|
1390 |
|
---|
1391 | Example:
|
---|
1392 |
|
---|
1393 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 34
|
---|
1394 |
|
---|
1395 |
|
---|
1396 | Often, it is required to set a fill pattern similar to the styles
|
---|
1397 | in Qt::BrushStyle. You can use the background-color property for
|
---|
1398 | Qt::SolidPattern, Qt::RadialGradientPattern, Qt::LinearGradientPattern
|
---|
1399 | and Qt::ConicalGradientPattern. The other patterns are easily achieved
|
---|
1400 | by creating a background image that contains the pattern.
|
---|
1401 |
|
---|
1402 | Example:
|
---|
1403 |
|
---|
1404 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 35
|
---|
1405 |
|
---|
1406 | See also \l{#background-origin-prop}{background-origin},
|
---|
1407 | \l{#selection-background-color-prop}{selection-background-color},
|
---|
1408 | \l{#background-clip-prop}{background-clip},
|
---|
1409 | \l{#background-attachment-prop}{background-attachment}
|
---|
1410 | and \l{#alternate-background-color-prop}{alternate-background-color}.
|
---|
1411 |
|
---|
1412 | \row
|
---|
1413 | \o \c background-color \target background-color-prop
|
---|
1414 | \o \l{#Brush}{Brush} \BR
|
---|
1415 | \o The background color used for the widget.
|
---|
1416 |
|
---|
1417 | Examples:
|
---|
1418 |
|
---|
1419 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 36
|
---|
1420 |
|
---|
1421 | \row
|
---|
1422 | \o \c background-image \target background-image-prop
|
---|
1423 | \o \l{#Url}{Url}
|
---|
1424 | \o The background image used for the widget. Semi-transparent
|
---|
1425 | parts of the image let the \c background-color shine
|
---|
1426 | through.
|
---|
1427 |
|
---|
1428 | Example:
|
---|
1429 |
|
---|
1430 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 37
|
---|
1431 |
|
---|
1432 | \row
|
---|
1433 | \o \c background-repeat \target background-repeat-prop
|
---|
1434 | \o \l{#Repeat}{Repeat}
|
---|
1435 | \o Whether and how the background image is repeated to fill
|
---|
1436 | the \c background-origin rectangle.
|
---|
1437 |
|
---|
1438 | If this property is not specified, the background image
|
---|
1439 | is repeated in both directions (\c repeat).
|
---|
1440 |
|
---|
1441 | Example:
|
---|
1442 |
|
---|
1443 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 38
|
---|
1444 |
|
---|
1445 | \row
|
---|
1446 | \o \c background-position
|
---|
1447 | \o \l{#Alignment}{Alignment}
|
---|
1448 | \o The alignment of the background image within the \c
|
---|
1449 | background-origin rectangle.
|
---|
1450 |
|
---|
1451 | If this property is not specified, the alignment is \c
|
---|
1452 | top \c left.
|
---|
1453 |
|
---|
1454 | Example:
|
---|
1455 |
|
---|
1456 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 39
|
---|
1457 |
|
---|
1458 | \row
|
---|
1459 | \o \bold{\c background-attachment} \target background-attachment-prop
|
---|
1460 | \o \l{#Attachment}{Attachment}
|
---|
1461 | \o Determines whether the background-image in a QAbstractScrollArea
|
---|
1462 | is scrolled or fixed with respect to the viewport.
|
---|
1463 | By default, the background-image scrolls with the viewport.
|
---|
1464 |
|
---|
1465 | Example:
|
---|
1466 |
|
---|
1467 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 40
|
---|
1468 |
|
---|
1469 | See also \l{Qt Style Sheets Reference#background-prop}{background}
|
---|
1470 |
|
---|
1471 | \row
|
---|
1472 | \o \bold{\c background-clip} \target background-clip-prop
|
---|
1473 | \o \l{#Origin}{Origin}
|
---|
1474 | \o The widget's rectangle, in which the \c background is drawn.
|
---|
1475 |
|
---|
1476 | This property specifies the rectangle to which the \c background-color
|
---|
1477 | and \c background-image are clipped.
|
---|
1478 |
|
---|
1479 | This property is supported by QAbstractItemView
|
---|
1480 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1481 | QComboBox, QDialog, QFrame, QGroupBox, QLabel,
|
---|
1482 | QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip,
|
---|
1483 | and plain \l{QWidget}s.
|
---|
1484 |
|
---|
1485 | If this property is not specified, the default is \c
|
---|
1486 | border.
|
---|
1487 |
|
---|
1488 | Example:
|
---|
1489 |
|
---|
1490 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 41
|
---|
1491 |
|
---|
1492 | See also \l{Qt Style Sheets Reference#background-prop}{background},
|
---|
1493 | \l{#background-origin-prop}{background-origin} and \l{The Box Model}.
|
---|
1494 |
|
---|
1495 | \row
|
---|
1496 | \o \bold{\c background-origin} \target background-origin-prop
|
---|
1497 | \o \l{#Origin}{Origin}
|
---|
1498 | \o The widget's background rectangle, to use in conjunction
|
---|
1499 | with \c background-position and \c background-image.
|
---|
1500 |
|
---|
1501 | This property is supported by QAbstractItemView
|
---|
1502 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1503 | QComboBox, QDialog, QFrame, QGroupBox, QLabel,
|
---|
1504 | QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip,
|
---|
1505 | and plain \l{QWidget}s.
|
---|
1506 |
|
---|
1507 | If this property is not specified, the default is \c
|
---|
1508 | padding.
|
---|
1509 |
|
---|
1510 | Example:
|
---|
1511 |
|
---|
1512 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 42
|
---|
1513 |
|
---|
1514 | See also \l{Qt Style Sheets Reference#background-prop}{background} and
|
---|
1515 | \l{The Box Model}.
|
---|
1516 |
|
---|
1517 | \row
|
---|
1518 | \o \bold{\c border} \target border-prop
|
---|
1519 | \o \l{#Border}{Border}
|
---|
1520 | \o Shorthand notation for setting the widget's border. Equivalent
|
---|
1521 | to specifying \c border-color, \c border-style, and/or
|
---|
1522 | \c border-width.
|
---|
1523 |
|
---|
1524 | This property is supported by QAbstractItemView
|
---|
1525 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1526 | QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit,
|
---|
1527 | QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
|
---|
1528 | QTextEdit, QToolTip, and plain \l{QWidget}s.
|
---|
1529 |
|
---|
1530 | Example:
|
---|
1531 |
|
---|
1532 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 43
|
---|
1533 |
|
---|
1534 | \row
|
---|
1535 | \o \c border-top
|
---|
1536 | \o \l{#Border}{Border}
|
---|
1537 | \o Shorthand notation for setting the widget's top border.
|
---|
1538 | Equivalent to specifying \c border-top-color, \c
|
---|
1539 | border-top-style, and/or \c border-top-width.
|
---|
1540 |
|
---|
1541 | \row
|
---|
1542 | \o \c border-right
|
---|
1543 | \o \l{#Border}{Border}
|
---|
1544 | \o Shorthand notation for setting the widget's right border.
|
---|
1545 | Equivalent to specifying \c border-right-color, \c
|
---|
1546 | border-right-style, and/or \c border-right-width.
|
---|
1547 |
|
---|
1548 | \row
|
---|
1549 | \o \c border-bottom
|
---|
1550 | \o \l{#Border}{Border}
|
---|
1551 | \o Shorthand notation for setting the widget's bottom border.
|
---|
1552 | Equivalent to specifying \c border-bottom-color, \c
|
---|
1553 | border-bottom-style, and/or \c border-bottom-width.
|
---|
1554 |
|
---|
1555 | \row
|
---|
1556 | \o \c border-left
|
---|
1557 | \o \l{#Border}{Border}
|
---|
1558 | \o Shorthand notation for setting the widget's left border.
|
---|
1559 | Equivalent to specifying \c border-left-color, \c
|
---|
1560 | border-left-style, and/or \c border-left-width.
|
---|
1561 |
|
---|
1562 | \row
|
---|
1563 | \o \bold{\c border-color} \target border-attrs
|
---|
1564 | \target border-color-prop
|
---|
1565 | \o \l{#Box Colors}{Box Colors}
|
---|
1566 | \o The color of all the border's edges. Equivalent to
|
---|
1567 | specifying \c border-top-color, \c border-right-color, \c
|
---|
1568 | border-bottom-color, and \c border-left-color.
|
---|
1569 |
|
---|
1570 | This property is supported by QAbstractItemView
|
---|
1571 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1572 | QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit,
|
---|
1573 | QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
|
---|
1574 | QTextEdit, QToolTip, and plain \l{QWidget}s.
|
---|
1575 |
|
---|
1576 | If this property is not specified, it defaults to
|
---|
1577 | \l{#color-prop}{color} (i.e., the widget's foreground
|
---|
1578 | color).
|
---|
1579 |
|
---|
1580 | Example:
|
---|
1581 |
|
---|
1582 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 44
|
---|
1583 |
|
---|
1584 | See also \l{Qt Style Sheets Reference#border-style-prop}{border-style},
|
---|
1585 | \l{Qt Style Sheets Reference#border-width-prop}{border-width},
|
---|
1586 | \l{#border-image-prop}{border-image}, and \l{The Box Model}.
|
---|
1587 |
|
---|
1588 | \row
|
---|
1589 | \o \c border-top-color
|
---|
1590 | \o \l{#Brush}{Brush} \BR
|
---|
1591 | \o The color of the border's top edge.
|
---|
1592 |
|
---|
1593 | \row
|
---|
1594 | \o \c border-right-color
|
---|
1595 | \o \l{#Brush}{Brush} \BR
|
---|
1596 | \o The color of the border's right edge.
|
---|
1597 |
|
---|
1598 | \row
|
---|
1599 | \o \c border-bottom-color
|
---|
1600 | \o \l{#Brush}{Brush} \BR
|
---|
1601 | \o The color of the border's bottom edge.
|
---|
1602 |
|
---|
1603 | \row
|
---|
1604 | \o \c border-left-color
|
---|
1605 | \o \l{#Brush}{Brush} \BR
|
---|
1606 | \o The color of the border's left edge.
|
---|
1607 |
|
---|
1608 | \row
|
---|
1609 | \o \bold{\c border-image} \target border-image-prop
|
---|
1610 | \o \l{#Border Image}{Border Image}
|
---|
1611 | \o The image used to fill the border. The image is cut into
|
---|
1612 | nine parts and stretched appropriately if necessary. See
|
---|
1613 | \l{#Border Image}{Border Image} for details.
|
---|
1614 |
|
---|
1615 | This property is supported by QAbstractItemView
|
---|
1616 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1617 | QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit,
|
---|
1618 | QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
|
---|
1619 | QTextEdit and QToolTip.
|
---|
1620 |
|
---|
1621 | See also \l{#border-color-prop}{border-color},
|
---|
1622 | \l{Qt Style Sheets Reference#border-style-prop}{border-style},
|
---|
1623 | \l{Qt Style Sheets Reference#border-width-prop}{border-width}, and
|
---|
1624 | \l{The Box Model}.
|
---|
1625 |
|
---|
1626 | \row
|
---|
1627 | \o \bold{\c border-radius} \target border-radius-prop
|
---|
1628 | \o \l{#Radius}{Radius}
|
---|
1629 | \o The radius of the border's corners. Equivalent to
|
---|
1630 | specifying \c border-top-left-radius, \c
|
---|
1631 | border-top-right-radius, \c border-bottom-right-radius,
|
---|
1632 | and \c border-bottom-left-radius.
|
---|
1633 |
|
---|
1634 | The border-radius clips the element's
|
---|
1635 | \l{Qt Style Sheets Reference#background-prop}{background}.
|
---|
1636 |
|
---|
1637 | This property is supported by QAbstractItemView
|
---|
1638 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1639 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
1640 | QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
|
---|
1641 | and QToolTip.
|
---|
1642 |
|
---|
1643 | If this property is not specified, it defaults to 0.
|
---|
1644 |
|
---|
1645 | Example:
|
---|
1646 |
|
---|
1647 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 45
|
---|
1648 |
|
---|
1649 | See also \l{Qt Style Sheets Reference#border-width-prop}{border-width} and
|
---|
1650 | \l{The Box Model}.
|
---|
1651 |
|
---|
1652 | \row
|
---|
1653 | \o \c border-top-left-radius
|
---|
1654 | \o \l{#Radius}{Radius}
|
---|
1655 | \o The radius of the border's top-left corner.
|
---|
1656 |
|
---|
1657 | \row
|
---|
1658 | \o \c border-top-right-radius
|
---|
1659 | \o \l{#Radius}{Radius}
|
---|
1660 | \o The radius of the border's top-right corner.
|
---|
1661 |
|
---|
1662 | \row
|
---|
1663 | \o \c border-bottom-right-radius
|
---|
1664 | \o \l{#Radius}{Radius}
|
---|
1665 | \o The radius of the border's bottom-right corner. Setting
|
---|
1666 | this property to a positive value results in a rounded
|
---|
1667 | corner.
|
---|
1668 |
|
---|
1669 | \row
|
---|
1670 | \o \c border-bottom-left-radius
|
---|
1671 | \o \l{#Radius}{Radius}
|
---|
1672 | \o The radius of the border's bottom-left corner. Setting this
|
---|
1673 | property to a positive value results in a rounded corner.
|
---|
1674 |
|
---|
1675 | \row
|
---|
1676 | \o \bold{\c border-style} \target border-style-prop
|
---|
1677 | \o \l {Border Style}
|
---|
1678 | \o The style of all the border's edges.
|
---|
1679 |
|
---|
1680 | This property is supported by QAbstractItemView
|
---|
1681 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1682 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
1683 | QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
|
---|
1684 | and QToolTip.
|
---|
1685 |
|
---|
1686 | If this property is not specified, it defaults to \c none.
|
---|
1687 |
|
---|
1688 | Example:
|
---|
1689 |
|
---|
1690 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 46
|
---|
1691 |
|
---|
1692 | See also \l{#border-color-prop}{border-color},
|
---|
1693 | \l{Qt Style Sheets Reference#border-style-prop}{border-style},
|
---|
1694 | \l{#border-image-prop}{border-image}, and \l{The Box Model}.
|
---|
1695 |
|
---|
1696 | \row
|
---|
1697 | \o \c border-top-style
|
---|
1698 | \o \l{#Border Style}{Border Style}
|
---|
1699 | \o The style of the border's top edge.
|
---|
1700 |
|
---|
1701 | \row
|
---|
1702 | \o \c border-right-style
|
---|
1703 | \o \l{#Border Style}{Border Style}
|
---|
1704 | \o The style of the border's right edge/
|
---|
1705 |
|
---|
1706 | \row
|
---|
1707 | \o \c border-bottom-style
|
---|
1708 | \o \l{#Border Style}{Border Style}
|
---|
1709 | \o The style of the border's bottom edge.
|
---|
1710 |
|
---|
1711 | \row
|
---|
1712 | \o \c border-left-style
|
---|
1713 | \o \l{#Border Style}{Border Style}
|
---|
1714 | \o The style of the border's left edge.
|
---|
1715 |
|
---|
1716 | \row
|
---|
1717 | \o \bold{\c border-width} \target border-width-prop
|
---|
1718 | \o \l{#Box Lengths}{Box Lengths}
|
---|
1719 | \o The width of the border. Equivalent to setting \c
|
---|
1720 | border-top-width, \c border-right-width, \c
|
---|
1721 | border-bottom-width, and \c border-left-width.
|
---|
1722 |
|
---|
1723 | This property is supported by QAbstractItemView
|
---|
1724 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
1725 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
1726 | QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
|
---|
1727 | and QToolTip.
|
---|
1728 |
|
---|
1729 | Example:
|
---|
1730 |
|
---|
1731 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 47
|
---|
1732 |
|
---|
1733 | See also \l{#border-color-prop}{border-color},
|
---|
1734 | \l{#border-radius-prop}{border-radius},
|
---|
1735 | \l{Qt Style Sheets Reference#border-style-prop}{border-style},
|
---|
1736 | \l{#border-image-prop}{border-image}, and
|
---|
1737 | \l{The Box Model}.
|
---|
1738 |
|
---|
1739 | \row
|
---|
1740 | \o \c border-top-width
|
---|
1741 | \o \l{#Length}{Length}
|
---|
1742 | \o The width of the border's top edge.
|
---|
1743 |
|
---|
1744 | \row
|
---|
1745 | \o \c border-right-width
|
---|
1746 | \o \l{#Length}{Length}
|
---|
1747 | \o The width of the border's right edge.
|
---|
1748 |
|
---|
1749 | \row
|
---|
1750 | \o \c border-bottom-width
|
---|
1751 | \o \l{#Length}{Length}
|
---|
1752 | \o The width of the border's bottom edge.
|
---|
1753 |
|
---|
1754 | \row
|
---|
1755 | \o \c border-left-width
|
---|
1756 | \o \l{#Length}{Length}
|
---|
1757 | \o The width of the border's left edge.
|
---|
1758 |
|
---|
1759 | \row
|
---|
1760 | \o \bold{\c bottom} \target bottom-prop
|
---|
1761 | \o \l{#Length}{Length}
|
---|
1762 | \o If \l{#position-prop}{position} is \c relative (the
|
---|
1763 | default), moves a \l{subcontrol} by a certain offset up;
|
---|
1764 | specifying \tt{bottom: \e{y}} is then equivalent to
|
---|
1765 | specifying \tt{\l{Qt Style Sheets Reference#top-prop}{top}: -\e{y}}.
|
---|
1766 |
|
---|
1767 | If \l{#position-prop}{position} is \c absolute, the \c
|
---|
1768 | bottom property specifies the subcontrol's bottom edge
|
---|
1769 | in relation to the parent's bottom edge (see also
|
---|
1770 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}
|
---|
1771 | {subcontrol-origin}).
|
---|
1772 |
|
---|
1773 | Example:
|
---|
1774 |
|
---|
1775 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 48
|
---|
1776 |
|
---|
1777 | See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{#right-prop}{right}, and
|
---|
1778 | \l{Qt Style Sheets Reference#top-prop}{top}.
|
---|
1779 |
|
---|
1780 | \row
|
---|
1781 | \o \bold{\c button-layout} \target button-layout-prop
|
---|
1782 | \o \l{#Number}{Number}
|
---|
1783 | \o The layout of buttons in a QDialogButtonBox or
|
---|
1784 | a QMessageBox. The possible values are 0
|
---|
1785 | (\l{QDialogButtonBox::}{WinLayout}), 1
|
---|
1786 | (\l{QDialogButtonBox::}{MacLayout}), 2
|
---|
1787 | (\l{QDialogButtonBox::}{KdeLayout}), and 3
|
---|
1788 | (\l{QDialogButtonBox::}{GnomeLayout}).
|
---|
1789 |
|
---|
1790 | If this property is not specified, it defaults to the
|
---|
1791 | value specified by the current style for the
|
---|
1792 | \l{QStyle::}{SH_DialogButtonLayout} style hint.
|
---|
1793 |
|
---|
1794 | Example:
|
---|
1795 |
|
---|
1796 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 49
|
---|
1797 |
|
---|
1798 | \row
|
---|
1799 | \o \bold{\c color} \target color-prop
|
---|
1800 | \o \l{#Brush}{Brush} \BR
|
---|
1801 | \o The color used to render text.
|
---|
1802 |
|
---|
1803 | This property is supported by all widgets that respect
|
---|
1804 | the \l QWidget::palette.
|
---|
1805 |
|
---|
1806 | If this property is not set, the default is whatever is
|
---|
1807 | set for in the widget's palette for the
|
---|
1808 | QWidget::foregroundRole (typically black).
|
---|
1809 |
|
---|
1810 | Example:
|
---|
1811 |
|
---|
1812 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 50
|
---|
1813 |
|
---|
1814 | See also \l{Qt Style Sheets Reference#background-prop}{background} and
|
---|
1815 | \l{#selection-color-prop}{selection-color}.
|
---|
1816 |
|
---|
1817 | \row
|
---|
1818 | \o \bold{\c dialogbuttonbox-buttons-have-icons}
|
---|
1819 | \o \l{#Boolean}{Boolean}
|
---|
1820 | \o Whether the buttons in a QDialogButtonBox show icons
|
---|
1821 |
|
---|
1822 | If this property is set to 1, the buttons of a QDialogButtonBox
|
---|
1823 | show icons; if it is set to 0, the icons are not shown.
|
---|
1824 |
|
---|
1825 | See the \l{Qt Style Sheets Reference#list of icons}{List of Icons}
|
---|
1826 | section for information on how to set icons.
|
---|
1827 |
|
---|
1828 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 51
|
---|
1829 |
|
---|
1830 | \note Styles defining this property must be applied before the
|
---|
1831 | QDialogButtonBox is created; this means that you must apply the
|
---|
1832 | style to the parent widget or to the application itself.
|
---|
1833 |
|
---|
1834 | \omit
|
---|
1835 | \row
|
---|
1836 | \o \bold{\c etch-disabled-text}*
|
---|
1837 | \o \l{#Boolean}{Boolean}
|
---|
1838 | \o Whether disabled text is drawn etched.
|
---|
1839 |
|
---|
1840 | If this property is not specified, it defaults to the
|
---|
1841 | value specified by the current style for the
|
---|
1842 | \l{QStyle::}{SH_EtchDisabledText} style hint.
|
---|
1843 |
|
---|
1844 | Example:
|
---|
1845 |
|
---|
1846 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 52
|
---|
1847 | \endomit
|
---|
1848 |
|
---|
1849 | \row
|
---|
1850 | \o \bold{\c font} \target font-prop
|
---|
1851 | \o \l{#Font}{Font}
|
---|
1852 | \o Shorthand notation for setting the text's font. Equivalent
|
---|
1853 | to specifying \c font-family, \c font-size, \c font-style,
|
---|
1854 | and/or \c font-weight.
|
---|
1855 |
|
---|
1856 | This property is supported by all widgets that respect
|
---|
1857 | the \l QWidget::font.
|
---|
1858 |
|
---|
1859 | If this property is not set, the default is the
|
---|
1860 | QWidget::font.
|
---|
1861 |
|
---|
1862 | Example:
|
---|
1863 |
|
---|
1864 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 53
|
---|
1865 |
|
---|
1866 | \row
|
---|
1867 | \o \c font-family
|
---|
1868 | \o String
|
---|
1869 | \o The font family.
|
---|
1870 |
|
---|
1871 | Example:
|
---|
1872 |
|
---|
1873 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 54
|
---|
1874 |
|
---|
1875 | \note If you specify more than one parameter in \c font-family,
|
---|
1876 | e.g., \c{font-family: Verdana, Arial}, Qt will only use the first
|
---|
1877 | font. If it cannot be found, Qt uses the system fallbacks instead.
|
---|
1878 |
|
---|
1879 | \row
|
---|
1880 | \o \c font-size
|
---|
1881 | \o \l{#Font Size}{Font Size}
|
---|
1882 | \o The font size. In this version of Qt, only pt and px metrics are
|
---|
1883 | supported.
|
---|
1884 |
|
---|
1885 | Example:
|
---|
1886 |
|
---|
1887 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 55
|
---|
1888 |
|
---|
1889 | \row
|
---|
1890 | \o \c font-style
|
---|
1891 | \o \l {Font Style}
|
---|
1892 | \o The font style.
|
---|
1893 |
|
---|
1894 | Example:
|
---|
1895 |
|
---|
1896 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 56
|
---|
1897 |
|
---|
1898 | \row
|
---|
1899 | \o \c font-weight
|
---|
1900 | \o \l{#Font Weight}{Font Weight}
|
---|
1901 | \o The weight of the font.
|
---|
1902 |
|
---|
1903 | \row
|
---|
1904 | \o \bold{\c gridline-color}* \target gridline-color-prop
|
---|
1905 | \o \l{#Color}{Color} \BR
|
---|
1906 | \o The color of the grid line in a QTableView.
|
---|
1907 |
|
---|
1908 | If this property is not specified, it defaults to the
|
---|
1909 | value specified by the current style for the
|
---|
1910 | \l{QStyle::}{SH_Table_GridLineColor} style hint.
|
---|
1911 |
|
---|
1912 | Example:
|
---|
1913 |
|
---|
1914 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 57
|
---|
1915 |
|
---|
1916 | \row
|
---|
1917 | \o \bold{\c height} \target height-prop
|
---|
1918 | \o \l{#Length}{Length}
|
---|
1919 | \o The height of a \l{subcontrol} (or in some case, a widget).
|
---|
1920 |
|
---|
1921 | If this property is not specified, it defaults to a value
|
---|
1922 | that depends on the subcontrol/widget and on the current style.
|
---|
1923 |
|
---|
1924 | \warning Unless otherwise specified, this property has no effect
|
---|
1925 | when set on widgets. If you want a widget with a fixed height, set
|
---|
1926 | the \l{#min-width-prop}{min-height} and
|
---|
1927 | \l{#max-width-prop}{max-height} to the same value.
|
---|
1928 |
|
---|
1929 | Example:
|
---|
1930 |
|
---|
1931 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 58
|
---|
1932 |
|
---|
1933 | See also \l{#width-prop}{width}.
|
---|
1934 |
|
---|
1935 | \row
|
---|
1936 | \o \bold{\c icon-size} \target icon-size-prop
|
---|
1937 | \o \l{#Length}{Length}
|
---|
1938 | \o The width and height of the icon in a widget.
|
---|
1939 |
|
---|
1940 | The icon size of the following widgets can be set using this
|
---|
1941 | property.
|
---|
1942 | \list
|
---|
1943 | \i QCheckBox
|
---|
1944 | \i QListView
|
---|
1945 | \i QPushButton
|
---|
1946 | \i QRadioButton
|
---|
1947 | \i QTabBar
|
---|
1948 | \i QToolBar
|
---|
1949 | \i QToolBox
|
---|
1950 | \i QTreeView
|
---|
1951 | \endlist
|
---|
1952 |
|
---|
1953 | \row
|
---|
1954 | \o \bold{\c image}* \target image-prop
|
---|
1955 | \o \l{#Url}{Url}+
|
---|
1956 | \o The image that is drawn in the contents rectangle of a
|
---|
1957 | \l{subcontrol}.
|
---|
1958 |
|
---|
1959 | The image property accepts a list of \l{#Url}{Url}s or
|
---|
1960 | an \c{svg}. The actual image that is drawn is determined
|
---|
1961 | using the same algorithm as QIcon (i.e) the image is never scaled
|
---|
1962 | up but always scaled down if necessary. If a \c{svg} is specified,
|
---|
1963 | the image is scaled to the size of the contents rectangle.
|
---|
1964 |
|
---|
1965 | Setting the image property on sub controls implicitly sets the
|
---|
1966 | width and height of the sub-control (unless the image in a SVG).
|
---|
1967 |
|
---|
1968 | In Qt 4.3 and later, the alignment of the
|
---|
1969 | image within the rectangle can be specified using
|
---|
1970 | \l{image-position-prop}{image-position}.
|
---|
1971 |
|
---|
1972 | \warning The QIcon SVG plugin is needed to render SVG images.
|
---|
1973 |
|
---|
1974 | Example:
|
---|
1975 |
|
---|
1976 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 59
|
---|
1977 |
|
---|
1978 | \row
|
---|
1979 | \o \bold{\c image-position} \target image-position-prop
|
---|
1980 | \o \l{#Alignment}{alignment}
|
---|
1981 | \o In Qt 4.3 and later, the alignment of the image image's position can be specified
|
---|
1982 | using relative or absolute position.
|
---|
1983 |
|
---|
1984 | \row
|
---|
1985 | \o \bold{\c left} \target left-prop
|
---|
1986 | \o \l{#Length}{Length}
|
---|
1987 | \o If \l{#position-prop}{position} is \c relative (the
|
---|
1988 | default), moves a \l{subcontrol} by a certain offset to
|
---|
1989 | the right.
|
---|
1990 |
|
---|
1991 | If \l{#position-prop}{position} is \c absolute, the \c
|
---|
1992 | left property specifies the subcontrol's left edge in
|
---|
1993 | relation to the parent's left edge (see also
|
---|
1994 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
|
---|
1995 |
|
---|
1996 | If this property is not specified, it defaults to \c 0.
|
---|
1997 |
|
---|
1998 | Example:
|
---|
1999 |
|
---|
2000 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 60
|
---|
2001 |
|
---|
2002 | See also \l{#right-prop}{right}, \l{Qt Style Sheets Reference#top-prop}{top}, and
|
---|
2003 | \l{#bottom-prop}{bottom}.
|
---|
2004 |
|
---|
2005 | \row
|
---|
2006 | \o \bold{\c lineedit-password- \BR \c character}* \target lineedit-password-character-prop
|
---|
2007 | \o \l{#Number}{Number}
|
---|
2008 | \o The QLineEdit password character as a Unicode number.
|
---|
2009 |
|
---|
2010 | If this property is not specified, it defaults to the
|
---|
2011 | value specified by the current style for the
|
---|
2012 | \l{QStyle::}{SH_LineEdit_PasswordCharacter} style hint.
|
---|
2013 |
|
---|
2014 | Example:
|
---|
2015 |
|
---|
2016 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 61
|
---|
2017 |
|
---|
2018 | \row
|
---|
2019 | \o \bold{\c margin} \target margin-prop
|
---|
2020 | \o \l {Box Lengths}
|
---|
2021 | \o The widget's margins. Equivalent to specifying \c
|
---|
2022 | margin-top, \c margin-right, \c margin-bottom, and \c
|
---|
2023 | margin-left.
|
---|
2024 |
|
---|
2025 | This property is supported by QAbstractItemView
|
---|
2026 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2027 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2028 | QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
|
---|
2029 | and QToolTip.
|
---|
2030 |
|
---|
2031 | If this property is not specified, it defaults to \c 0.
|
---|
2032 |
|
---|
2033 | Example:
|
---|
2034 |
|
---|
2035 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 62
|
---|
2036 |
|
---|
2037 | See also \l{Qt Style Sheets Reference#padding-prop}{padding},
|
---|
2038 | \l{#spacing-prop}{spacing}, and \l{The Box Model}.
|
---|
2039 |
|
---|
2040 | \row
|
---|
2041 | \o \c margin-top
|
---|
2042 | \o \l{#Length}{Length}
|
---|
2043 | \o The widget's top margin.
|
---|
2044 |
|
---|
2045 | \row
|
---|
2046 | \o \c margin-right
|
---|
2047 | \o \l{#Length}{Length}
|
---|
2048 | \o The widget's right margin.
|
---|
2049 |
|
---|
2050 | \row
|
---|
2051 | \o \c margin-bottom
|
---|
2052 | \o \l{#Length}{Length}
|
---|
2053 | \o The widget's bottom margin.
|
---|
2054 |
|
---|
2055 | \row
|
---|
2056 | \o \c margin-left
|
---|
2057 | \o \l{#Length}{Length}
|
---|
2058 | \o The widget's left margin.
|
---|
2059 |
|
---|
2060 | \row
|
---|
2061 | \o \bold{\c max-height} \target max-height-prop
|
---|
2062 | \o \l{#Length}{Length}
|
---|
2063 | \o The widget's or a subcontrol's maximum height.
|
---|
2064 |
|
---|
2065 | This property is supported by QAbstractItemView
|
---|
2066 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2067 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2068 | QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
|
---|
2069 | QSplitter, QStatusBar, QTextEdit, and QToolTip.
|
---|
2070 |
|
---|
2071 | Example:
|
---|
2072 |
|
---|
2073 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 63
|
---|
2074 |
|
---|
2075 | See also \l{#max-width-prop}{max-width}.
|
---|
2076 |
|
---|
2077 | \row
|
---|
2078 | \o \bold{\c max-width} \target max-width-prop
|
---|
2079 | \o \l{#Length}{Length}
|
---|
2080 | \o The widget's or a subcontrol's maximum width.
|
---|
2081 |
|
---|
2082 | This property is supported by QAbstractItemView
|
---|
2083 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2084 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2085 | QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
|
---|
2086 | QSplitter, QStatusBar, QTextEdit, and QToolTip.
|
---|
2087 |
|
---|
2088 | Example:
|
---|
2089 |
|
---|
2090 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 64
|
---|
2091 |
|
---|
2092 | See also \l{#max-height-prop}{max-height}.
|
---|
2093 |
|
---|
2094 |
|
---|
2095 | \row
|
---|
2096 | \o \bold{\c messagebox-text- \target messagebox-text-interaction-flags-prop
|
---|
2097 | \BR \c interaction-flags}*
|
---|
2098 | \o \l{#Number}{Number}
|
---|
2099 | \o The interaction behavior for text in a message box.
|
---|
2100 | Possible values are based on Qt::TextInteractionFlags.
|
---|
2101 |
|
---|
2102 | If this property is not specified, it defaults to the
|
---|
2103 | value specified by the current style for the
|
---|
2104 | \l{QStyle::}{SH_MessageBox_TextInteractionFlags} style
|
---|
2105 | hint.
|
---|
2106 |
|
---|
2107 | Example:
|
---|
2108 |
|
---|
2109 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 65
|
---|
2110 |
|
---|
2111 | \row
|
---|
2112 | \o \bold{\c min-height} \target min-height-prop
|
---|
2113 | \o \l{#Length}{Length}
|
---|
2114 | \o The widget's or a subcontrol's minimum height.
|
---|
2115 |
|
---|
2116 | This property is supported by QAbstractItemView
|
---|
2117 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2118 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2119 | QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
|
---|
2120 | QSplitter, QStatusBar, QTextEdit, and QToolTip.
|
---|
2121 |
|
---|
2122 | If this property is not specified, the minimum height is
|
---|
2123 | derived based on the widget's contents and the style.
|
---|
2124 |
|
---|
2125 | Example:
|
---|
2126 |
|
---|
2127 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 66
|
---|
2128 |
|
---|
2129 | See also \l{#min-width-prop}{min-width}.
|
---|
2130 |
|
---|
2131 | \row
|
---|
2132 | \o \bold{\c min-width} \target min-width-prop
|
---|
2133 | \o \l{#Length}{Length}
|
---|
2134 | \o The widget's or a subcontrol's minimum width.
|
---|
2135 |
|
---|
2136 | This property is supported by QAbstractItemView
|
---|
2137 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2138 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2139 | QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
|
---|
2140 | QSplitter, QStatusBar, QTextEdit, and QToolTip.
|
---|
2141 |
|
---|
2142 | If this property is not specified, the minimum width is
|
---|
2143 | derived based on the widget's contents and the style.
|
---|
2144 |
|
---|
2145 | Example:
|
---|
2146 |
|
---|
2147 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 67
|
---|
2148 |
|
---|
2149 | See also \l{#min-height-prop}{min-height}.
|
---|
2150 |
|
---|
2151 | \row
|
---|
2152 | \o \bold{\c opacity}* \target opacity-prop
|
---|
2153 | \o \l{#Number}{Number}
|
---|
2154 | \o The opacity for a widget. Possible values are from 0
|
---|
2155 | (transparent) to 255 (opaque). For the moment, this is
|
---|
2156 | only supported for \l{QToolTip}{tooltips}.
|
---|
2157 |
|
---|
2158 | If this property is not specified, it defaults to the
|
---|
2159 | value specified by the current style for the
|
---|
2160 | \l{QStyle::}{SH_ToolTipLabel_Opacity} style hint.
|
---|
2161 |
|
---|
2162 | Example:
|
---|
2163 |
|
---|
2164 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 68
|
---|
2165 |
|
---|
2166 | \row
|
---|
2167 | \o \bold{\c padding} \target padding-prop
|
---|
2168 | \o \l{#Box Lengths}{Box Lengths}
|
---|
2169 | \o The widget's padding. Equivalent to specifying \c
|
---|
2170 | padding-top, \c padding-right, \c padding-bottom, and \c
|
---|
2171 | padding-left.
|
---|
2172 |
|
---|
2173 | This property is supported by QAbstractItemView
|
---|
2174 | subclasses, QAbstractSpinBox subclasses, QCheckBox,
|
---|
2175 | QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
|
---|
2176 | QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
|
---|
2177 | and QToolTip.
|
---|
2178 |
|
---|
2179 | If this property is not specified, it defaults to \c 0.
|
---|
2180 |
|
---|
2181 | Example:
|
---|
2182 |
|
---|
2183 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 69
|
---|
2184 |
|
---|
2185 | See also \l{#margin-prop}{margin},
|
---|
2186 | \l{#spacing-prop}{spacing}, and \l{The Box Model}.
|
---|
2187 |
|
---|
2188 | \row
|
---|
2189 | \o \c padding-top
|
---|
2190 | \o \l{#Length}{Length}
|
---|
2191 | \o The widget's top padding.
|
---|
2192 |
|
---|
2193 | \row
|
---|
2194 | \o \c padding-right
|
---|
2195 | \o \l{#Length}{Length}
|
---|
2196 | \o The widget's right padding.
|
---|
2197 |
|
---|
2198 | \row
|
---|
2199 | \o \c padding-bottom
|
---|
2200 | \o \l{#Length}{Length}
|
---|
2201 | \o The widget's bottom padding.
|
---|
2202 |
|
---|
2203 | \row
|
---|
2204 | \o \c padding-left
|
---|
2205 | \o \l{#Length}{Length}
|
---|
2206 | \o The widget's left padding.
|
---|
2207 |
|
---|
2208 | \row
|
---|
2209 | \o \bold{\c paint-alternating-row-colors-for-empty-area}
|
---|
2210 | \target paint-alternating-row-colors-for-empty-area-prop
|
---|
2211 | \o \c bool
|
---|
2212 | \o Whether the QTreeView paints alternating row colors for the empty
|
---|
2213 | area (i.e the area where there are no items)
|
---|
2214 |
|
---|
2215 | \row
|
---|
2216 | \o \bold{\c position} \target position-prop
|
---|
2217 | \o \c relative \BR
|
---|
2218 | | \c absolute
|
---|
2219 | \o Whether offsets specified using \l{Qt Style Sheets Reference#left-prop}{left},
|
---|
2220 | \l{#right-prop}{right}, \l{Qt Style Sheets Reference#top-prop}{top}, and
|
---|
2221 | \l{#bottom-prop}{bottom} are relative or absolute
|
---|
2222 | coordinates.
|
---|
2223 |
|
---|
2224 | If this property is not specified, it defaults to \c
|
---|
2225 | relative.
|
---|
2226 |
|
---|
2227 | \row
|
---|
2228 | \o \bold{\c right} \target right-prop
|
---|
2229 | \o \l{#Length}{Length}
|
---|
2230 | \o If \l{#position-prop}{position} is \c relative (the
|
---|
2231 | default), moves a \l{subcontrol} by a certain offset to
|
---|
2232 | the left; specifying \tt{right: \e{x}} is then equivalent
|
---|
2233 | to specifying \tt{\l{Qt Style Sheets Reference#left-prop}{left}: -\e{x}}.
|
---|
2234 |
|
---|
2235 | If \l{#position-prop}{position} is \c absolute, the \c
|
---|
2236 | right property specifies the subcontrol's right edge in
|
---|
2237 | relation to the parent's right edge (see also
|
---|
2238 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
|
---|
2239 |
|
---|
2240 | Example:
|
---|
2241 |
|
---|
2242 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 70
|
---|
2243 |
|
---|
2244 | See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{Qt Style Sheets Reference#top-prop}{top}, and
|
---|
2245 | \l{#bottom-prop}{bottom}.
|
---|
2246 |
|
---|
2247 | \row
|
---|
2248 | \o \bold{\c selection-background-color}* \target selection-background-color-prop
|
---|
2249 | \o \l{#Brush}{Brush} \BR
|
---|
2250 | \o The background of selected text or items.
|
---|
2251 |
|
---|
2252 | This property is supported by all widgets that respect
|
---|
2253 | the \l QWidget::palette and that show selection text.
|
---|
2254 |
|
---|
2255 | If this property is not set, the default value is
|
---|
2256 | whatever is set for the palette's
|
---|
2257 | \l{QPalette::}{Highlight} role.
|
---|
2258 |
|
---|
2259 | Example:
|
---|
2260 |
|
---|
2261 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 71
|
---|
2262 |
|
---|
2263 | See also \l{#selection-color-prop}{selection-color} and
|
---|
2264 | \l{Qt Style Sheets Reference#background-prop}{background}.
|
---|
2265 |
|
---|
2266 | \row
|
---|
2267 | \o \bold{\c selection-color}* \target selection-color-prop
|
---|
2268 | \o \l{#Brush}{Brush} \BR
|
---|
2269 | \o The foreground of selected text or items.
|
---|
2270 |
|
---|
2271 | This property is supported by all widgets that respect
|
---|
2272 | the \l QWidget::palette and that show selection text.
|
---|
2273 |
|
---|
2274 | If this property is not set, the default value is
|
---|
2275 | whatever is set for the palette's
|
---|
2276 | \l{QPalette::}{HighlightedText} role.
|
---|
2277 |
|
---|
2278 | Example:
|
---|
2279 |
|
---|
2280 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 72
|
---|
2281 |
|
---|
2282 | See also
|
---|
2283 | \l{#selection-background-color-prop}{selection-background-color}
|
---|
2284 | and \l{#color-prop}{color}.
|
---|
2285 |
|
---|
2286 | \row
|
---|
2287 | \o \bold{\c show-decoration- \target show-decoration-selected-prop
|
---|
2288 | \BR \c selected}*
|
---|
2289 | \o \l{#Boolean}{Boolean}
|
---|
2290 | \o Controls whether selections in a QListView cover the
|
---|
2291 | entire row or just the extent of the text.
|
---|
2292 |
|
---|
2293 | If this property is not specified, it defaults to the
|
---|
2294 | value specified by the current style for the
|
---|
2295 | \l{QStyle::}{SH_ItemView_ShowDecorationSelected} style
|
---|
2296 | hint.
|
---|
2297 |
|
---|
2298 | Example:
|
---|
2299 |
|
---|
2300 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 73
|
---|
2301 |
|
---|
2302 | \row
|
---|
2303 | \o \bold{\c spacing}* \target spacing-prop
|
---|
2304 | \o \l{#Length}{Length}
|
---|
2305 | \o Internal spacing in the widget.
|
---|
2306 |
|
---|
2307 | This property is supported by QCheckBox, checkable
|
---|
2308 | \l{QGroupBox}es, QMenuBar, and QRadioButton.
|
---|
2309 |
|
---|
2310 | If this property is not specified, the default value
|
---|
2311 | depends on the widget and on the current style.
|
---|
2312 |
|
---|
2313 | Example:
|
---|
2314 |
|
---|
2315 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 74
|
---|
2316 |
|
---|
2317 | See also \l{Qt Style Sheets Reference#padding-prop}{padding} and
|
---|
2318 | \l{#margin-prop}{margin}.
|
---|
2319 |
|
---|
2320 | \row
|
---|
2321 | \o \bold{\c subcontrol-origin}* \target subcontrol-origin-prop
|
---|
2322 | \o \l{#Origin}{Origin}
|
---|
2323 | \o The origin rectangle of the \l subcontrol within the
|
---|
2324 | parent element.
|
---|
2325 |
|
---|
2326 | If this property is not specified, the default is \c
|
---|
2327 | padding.
|
---|
2328 |
|
---|
2329 | Example:
|
---|
2330 |
|
---|
2331 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 75
|
---|
2332 |
|
---|
2333 | See also
|
---|
2334 | \l{Qt Style Sheets Reference#subcontrol-position-prop}{subcontrol-position}.
|
---|
2335 |
|
---|
2336 | \row
|
---|
2337 | \o \bold{\c subcontrol-position}* \target subcontrol-position-prop
|
---|
2338 | \o \l{#Alignment}{Alignment}
|
---|
2339 | \o The alignment of the \l subcontrol within the origin
|
---|
2340 | rectangle specified by \l{Qt Style Sheets Reference#subcontrol-origin-prop}
|
---|
2341 | {subcontrol-origin}.
|
---|
2342 |
|
---|
2343 | If this property is not specified, it defaults to a value
|
---|
2344 | that depends on the subcontrol.
|
---|
2345 |
|
---|
2346 | Example:
|
---|
2347 |
|
---|
2348 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 76
|
---|
2349 |
|
---|
2350 | See also
|
---|
2351 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}.
|
---|
2352 |
|
---|
2353 | \row
|
---|
2354 | \o \bold{\c text-align} \target text-align-prop
|
---|
2355 | \o \l{#Alignment}{Alignment}
|
---|
2356 | \o The alignment of text and icon within the contents of the widget.
|
---|
2357 |
|
---|
2358 | If this value is not specified, it defaults to the value
|
---|
2359 | that depends on the native style.
|
---|
2360 |
|
---|
2361 | Example:
|
---|
2362 |
|
---|
2363 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 77
|
---|
2364 |
|
---|
2365 | This property is currently supported only by QPushButton
|
---|
2366 | and QProgressBar.
|
---|
2367 |
|
---|
2368 | \row
|
---|
2369 | \o \bold{\c text-decoration}
|
---|
2370 | \o \c none \BR
|
---|
2371 | \c underline \BR
|
---|
2372 | \c overline \BR
|
---|
2373 | \c line-through
|
---|
2374 | \o Additional text effects
|
---|
2375 |
|
---|
2376 | \row
|
---|
2377 | \o \bold{\c top} \target top-prop
|
---|
2378 | \o \l{#Length}{Length}
|
---|
2379 | \o If \l{#position-prop}{position} is \c relative (the
|
---|
2380 | default), moves a \l{subcontrol} by a certain offset
|
---|
2381 | down.
|
---|
2382 |
|
---|
2383 | If \l{#position-prop}{position} is \c absolute, the \c top
|
---|
2384 | property specifies the subcontrol's top edge in relation
|
---|
2385 | to the parent's top edge (see also
|
---|
2386 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
|
---|
2387 |
|
---|
2388 | If this property is not specified, it defaults to \c 0.
|
---|
2389 |
|
---|
2390 | Example:
|
---|
2391 |
|
---|
2392 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 78
|
---|
2393 |
|
---|
2394 | See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{#right-prop}{right}, and
|
---|
2395 | \l{#bottom-prop}{bottom}.
|
---|
2396 |
|
---|
2397 | \row
|
---|
2398 | \o \bold{\c width} \target width-prop
|
---|
2399 | \o \l{#Length}{Length}
|
---|
2400 | \o The width of a \l{subcontrol} (or a widget in some cases).
|
---|
2401 |
|
---|
2402 | If this property is not specified, it defaults to a value
|
---|
2403 | that depends on the subcontrol/widget and on the current style.
|
---|
2404 |
|
---|
2405 | \warning Unless otherwise specified, this property has no effect
|
---|
2406 | when set on widgets. If you want a widget with a fixed width, set
|
---|
2407 | the \l{#min-width-prop}{min-width} and
|
---|
2408 | \l{#max-width-prop}{max-width} to the same value.
|
---|
2409 |
|
---|
2410 | Example:
|
---|
2411 |
|
---|
2412 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 79
|
---|
2413 |
|
---|
2414 | See also \l{#height-prop}{height}.
|
---|
2415 |
|
---|
2416 | \endtable
|
---|
2417 |
|
---|
2418 | \target list of icons
|
---|
2419 | \section1 List of Icons
|
---|
2420 |
|
---|
2421 | Icons used in Qt can be customized using the following properties. Each of
|
---|
2422 | the properties listed in this section have the type \l{#Icon}{Icon}.
|
---|
2423 |
|
---|
2424 | Note that for icons to appear in buttons in a QDialogButtonBox, you need to
|
---|
2425 | set the dialogbuttonbox-buttons-have-icons property to true. Also, to
|
---|
2426 | customize the size of the icons, use the icon-size property.
|
---|
2427 |
|
---|
2428 | \table 100%
|
---|
2429 | \header
|
---|
2430 | \o Name
|
---|
2431 | \o QStyle::StandardPixmap
|
---|
2432 |
|
---|
2433 | \row
|
---|
2434 | \o backward-icon
|
---|
2435 | \o QStyle::SP_ArrowBack
|
---|
2436 |
|
---|
2437 | \row
|
---|
2438 | \o cd-icon
|
---|
2439 | \o QStyle::SP_DriveCDIcon
|
---|
2440 |
|
---|
2441 | \row
|
---|
2442 | \o computer-icon
|
---|
2443 | \o QStyle::SP_ComputerIcon
|
---|
2444 |
|
---|
2445 | \row
|
---|
2446 | \o desktop-icon
|
---|
2447 | \o QStyle::SP_DesktopIcon
|
---|
2448 |
|
---|
2449 | \row
|
---|
2450 | \o dialog-apply-icon
|
---|
2451 | \o QStyle::SP_DialogApplyButton
|
---|
2452 |
|
---|
2453 | \row
|
---|
2454 | \o dialog-cancel-icon
|
---|
2455 | \o QStyle::SP_DialogCancelButton
|
---|
2456 |
|
---|
2457 | \row
|
---|
2458 | \o dialog-close-icon
|
---|
2459 | \o QStyle::SP_DialogCloseButton
|
---|
2460 |
|
---|
2461 | \row
|
---|
2462 | \o dialog-discard-icon
|
---|
2463 | \o QStyle::SP_DialogDiscardButton
|
---|
2464 |
|
---|
2465 | \row
|
---|
2466 | \o dialog-help-icon
|
---|
2467 | \o QStyle::SP_DialogHelpButton
|
---|
2468 |
|
---|
2469 | \row
|
---|
2470 | \o dialog-no-icon
|
---|
2471 | \o QStyle::SP_DialogNoButton
|
---|
2472 |
|
---|
2473 | \row
|
---|
2474 | \o dialog-ok-icon
|
---|
2475 | \o QStyle::SP_DialogOkButton
|
---|
2476 |
|
---|
2477 | \row
|
---|
2478 | \o dialog-open-icon
|
---|
2479 | \o QStyle::SP_DialogOpenButton
|
---|
2480 |
|
---|
2481 | \row
|
---|
2482 | \o dialog-reset-icon
|
---|
2483 | \o QStyle::SP_DialogResetButton
|
---|
2484 |
|
---|
2485 | \row
|
---|
2486 | \o dialog-save-icon
|
---|
2487 | \o QStyle::SP_DialogSaveButton
|
---|
2488 |
|
---|
2489 | \row
|
---|
2490 | \o dialog-yes-icon
|
---|
2491 | \o QStyle::SP_DialogYesButton
|
---|
2492 |
|
---|
2493 | \row
|
---|
2494 | \o directory-closed-icon
|
---|
2495 | \o QStyle::SP_DirClosedIcon
|
---|
2496 |
|
---|
2497 | \row
|
---|
2498 | \o directory-icon
|
---|
2499 | \o QStyle::SP_DirIcon
|
---|
2500 |
|
---|
2501 | \row
|
---|
2502 | \o directory-link-icon
|
---|
2503 | \o QStyle::SP_DirLinkIcon
|
---|
2504 |
|
---|
2505 | \row
|
---|
2506 | \o directory-open-icon
|
---|
2507 | \o QStyle::SP_DirOpenIcon
|
---|
2508 |
|
---|
2509 | \row
|
---|
2510 | \o dockwidget-close-icon
|
---|
2511 | \o QStyle::SP_DockWidgetCloseButton
|
---|
2512 |
|
---|
2513 | \row
|
---|
2514 | \o downarrow-icon
|
---|
2515 | \o QStyle::SP_ArrowDown
|
---|
2516 |
|
---|
2517 | \row
|
---|
2518 | \o dvd-icon
|
---|
2519 | \o QStyle::SP_DriveDVDIcon
|
---|
2520 |
|
---|
2521 | \row
|
---|
2522 | \o file-icon
|
---|
2523 | \o QStyle::SP_FileIcon
|
---|
2524 |
|
---|
2525 | \row
|
---|
2526 | \o file-link-icon
|
---|
2527 | \o QStyle::SP_FileLinkIcon
|
---|
2528 |
|
---|
2529 | \omit
|
---|
2530 | \row
|
---|
2531 | \o filedialog-backward-icon
|
---|
2532 | \o QStyle::SP_FileDialogBack
|
---|
2533 | \endomit
|
---|
2534 |
|
---|
2535 | \row
|
---|
2536 | \o filedialog-contentsview-icon
|
---|
2537 | \o QStyle::SP_FileDialogContentsView
|
---|
2538 |
|
---|
2539 | \row
|
---|
2540 | \o filedialog-detailedview-icon
|
---|
2541 | \o QStyle::SP_FileDialogDetailedView
|
---|
2542 |
|
---|
2543 | \row
|
---|
2544 | \o filedialog-end-icon
|
---|
2545 | \o QStyle::SP_FileDialogEnd
|
---|
2546 |
|
---|
2547 | \row
|
---|
2548 | \o filedialog-infoview-icon
|
---|
2549 | \o QStyle::SP_FileDialogInfoView
|
---|
2550 |
|
---|
2551 | \row
|
---|
2552 | \o filedialog-listview-icon
|
---|
2553 | \o QStyle::SP_FileDialogListView
|
---|
2554 |
|
---|
2555 | \row
|
---|
2556 | \o filedialog-new-directory-icon
|
---|
2557 | \o QStyle::SP_FileDialogNewFolder
|
---|
2558 |
|
---|
2559 | \row
|
---|
2560 | \o filedialog-parent-directory-icon
|
---|
2561 | \o QStyle::SP_FileDialogToParent
|
---|
2562 |
|
---|
2563 | \row
|
---|
2564 | \o filedialog-start-icon
|
---|
2565 | \o QStyle::SP_FileDialogStart
|
---|
2566 |
|
---|
2567 | \row
|
---|
2568 | \o floppy-icon
|
---|
2569 | \o QStyle::SP_DriveFDIcon
|
---|
2570 |
|
---|
2571 | \row
|
---|
2572 | \o forward-icon
|
---|
2573 | \o QStyle::SP_ArrowForward
|
---|
2574 |
|
---|
2575 | \row
|
---|
2576 | \o harddisk-icon
|
---|
2577 | \o QStyle::SP_DriveHDIcon
|
---|
2578 |
|
---|
2579 | \row
|
---|
2580 | \o home-icon
|
---|
2581 | \o QStyle::SP_DirHomeIcon
|
---|
2582 |
|
---|
2583 | \row
|
---|
2584 | \o leftarrow-icon
|
---|
2585 | \o QStyle::SP_ArrowLeft
|
---|
2586 |
|
---|
2587 | \row
|
---|
2588 | \o messagebox-critical-icon
|
---|
2589 | \o QStyle::SP_MessageBoxCritical
|
---|
2590 |
|
---|
2591 | \row
|
---|
2592 | \o messagebox-information-icon
|
---|
2593 | \o QStyle::SP_MessageBoxInformation
|
---|
2594 |
|
---|
2595 | \row
|
---|
2596 | \o messagebox-question-icon
|
---|
2597 | \o QStyle::SP_MessageBoxQuestion
|
---|
2598 |
|
---|
2599 | \row
|
---|
2600 | \o messagebox-warning-icon
|
---|
2601 | \o QStyle::SP_MessageBoxWarning
|
---|
2602 |
|
---|
2603 | \row
|
---|
2604 | \o network-icon
|
---|
2605 | \o QStyle::SP_DriveNetIcon
|
---|
2606 |
|
---|
2607 | \row
|
---|
2608 | \o rightarrow-icon
|
---|
2609 | \o QStyle::SP_ArrowRight
|
---|
2610 |
|
---|
2611 | \row
|
---|
2612 | \o titlebar-contexthelp-icon
|
---|
2613 | \o QStyle::SP_TitleBarContextHelpButton
|
---|
2614 |
|
---|
2615 | \row
|
---|
2616 | \o titlebar-maximize-icon
|
---|
2617 | \o QStyle::SP_TitleBarMaxButton
|
---|
2618 |
|
---|
2619 | \row
|
---|
2620 | \o titlebar-menu-icon
|
---|
2621 | \o QStyle::SP_TitleBarMenuButton
|
---|
2622 |
|
---|
2623 | \row
|
---|
2624 | \o titlebar-minimize-icon
|
---|
2625 | \o QStyle::SP_TitleBarMinButton
|
---|
2626 |
|
---|
2627 | \row
|
---|
2628 | \o titlebar-normal-icon
|
---|
2629 | \o QStyle::SP_TitleBarNormalButton
|
---|
2630 |
|
---|
2631 | \row
|
---|
2632 | \o titlebar-shade-icon
|
---|
2633 | \o QStyle::SP_TitleBarShadeButton
|
---|
2634 |
|
---|
2635 | \row
|
---|
2636 | \o titlebar-unshade-icon
|
---|
2637 | \o QStyle::SP_TitleBarUnshadeButton
|
---|
2638 |
|
---|
2639 | \row
|
---|
2640 | \o trash-icon
|
---|
2641 | \o QStyle::SP_TrashIcon
|
---|
2642 |
|
---|
2643 | \row
|
---|
2644 | \o uparrow-icon
|
---|
2645 | \o QStyle::SP_ArrowUp
|
---|
2646 |
|
---|
2647 | \endtable
|
---|
2648 |
|
---|
2649 | \section1 List of Property Types
|
---|
2650 |
|
---|
2651 | The following table summarizes the syntax and meaning of the
|
---|
2652 | different property types.
|
---|
2653 |
|
---|
2654 | \table 100%
|
---|
2655 | \header
|
---|
2656 | \o Type
|
---|
2657 | \o Syntax
|
---|
2658 | \o Description
|
---|
2659 |
|
---|
2660 | \row
|
---|
2661 | \o \bold Alignment \target Alignment
|
---|
2662 | \o \{ \c top \BR
|
---|
2663 | | \c bottom \BR
|
---|
2664 | | \c left \BR
|
---|
2665 | | \c right \BR
|
---|
2666 | | \c center \}*
|
---|
2667 | \o Horizontal and/or vertical alignment.
|
---|
2668 |
|
---|
2669 | Example:
|
---|
2670 |
|
---|
2671 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 80
|
---|
2672 |
|
---|
2673 | \row
|
---|
2674 | \o \bold Attachment \target Attachment
|
---|
2675 | \o \{ \c scroll \BR
|
---|
2676 | | \c fixed \}*
|
---|
2677 | \o Scroll or fixed attachment.
|
---|
2678 |
|
---|
2679 | \row
|
---|
2680 | \o \bold Background \target Background
|
---|
2681 | \o \{ \l{#Brush}{Brush} \BR
|
---|
2682 | | \l{#Url}{Url} \BR
|
---|
2683 | | \l{#Repeat}{Repeat} \BR
|
---|
2684 | | \l{#Alignment}{Alignment} \}*
|
---|
2685 | \o A sequence of \l{#Brush}{Brush}, \l{#Url}{Url},
|
---|
2686 | \l{#Repeat}{Repeat}, and \l{#Alignment}{Alignment}.
|
---|
2687 |
|
---|
2688 | \row
|
---|
2689 | \o \bold Boolean \target Boolean
|
---|
2690 | \o 0 | 1
|
---|
2691 | \o True (\c 1) or false (\c 0).
|
---|
2692 |
|
---|
2693 | Example:
|
---|
2694 |
|
---|
2695 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 81
|
---|
2696 |
|
---|
2697 | \row
|
---|
2698 | \o \bold Border \target Border
|
---|
2699 | \o \{ \l{#Border Style}{Border Style} \BR
|
---|
2700 | | \l{#Length}{Length} \BR
|
---|
2701 | | \l{#Brush}{Brush} \}*
|
---|
2702 | \o Shorthand border property.
|
---|
2703 |
|
---|
2704 | \row
|
---|
2705 | \o \bold{Border \target Border Image
|
---|
2706 | Image}
|
---|
2707 | \o \c none \BR
|
---|
2708 | | \l{Url} \l{Number}\{4\} \BR (\c stretch | \c repeat){0,2}
|
---|
2709 | \o A border image is an image that is composed of nine parts
|
---|
2710 | (top left, top center, top right, center left, center,
|
---|
2711 | center right, bottom left, bottom center, and bottom
|
---|
2712 | right). When a border of a certain size is required, the
|
---|
2713 | corner parts are used as is, and the top, right, bottom,
|
---|
2714 | and left parts are stretched or repeated to produce a
|
---|
2715 | border with the desired size.
|
---|
2716 |
|
---|
2717 | See the
|
---|
2718 | \l{http://www.w3.org/TR/css3-background/#the-border-image}
|
---|
2719 | {CSS3 Draft Specification} for details.
|
---|
2720 |
|
---|
2721 | \row
|
---|
2722 | \o \bold{Border \target Border Style
|
---|
2723 | Style}
|
---|
2724 | \o \c dashed \BR
|
---|
2725 | | \c dot-dash \BR
|
---|
2726 | | \c dot-dot-dash \BR
|
---|
2727 | | \c dotted \BR
|
---|
2728 | | \c double \BR
|
---|
2729 | | \c groove \BR
|
---|
2730 | | \c inset \BR
|
---|
2731 | | \c outset \BR
|
---|
2732 | | \c ridge \BR
|
---|
2733 | | \c solid \BR
|
---|
2734 | | \c none
|
---|
2735 | \o Specifies the pattern used to draw a border.
|
---|
2736 | See the \l{http://www.w3.org/TR/css3-background/#border-style}
|
---|
2737 | {CSS3 Draft Specification} for details.
|
---|
2738 |
|
---|
2739 | \row
|
---|
2740 | \o \bold{Box \target Box Colors
|
---|
2741 | Colors}
|
---|
2742 | \o \l{#Brush}{Brush}\{1,4\}
|
---|
2743 | \o One to four occurrences of \l{#Brush}{Brush}, specifying the top,
|
---|
2744 | right, bottom, and left edges of a box, respectively. If
|
---|
2745 | the left color is not specified, it is taken to be the
|
---|
2746 | same as the right color. If the bottom color is not
|
---|
2747 | specified, it is taken to be the same as the top color. If
|
---|
2748 | the right color is not specified, it is taken to be the
|
---|
2749 | same as the top color.
|
---|
2750 |
|
---|
2751 | Example:
|
---|
2752 |
|
---|
2753 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 82
|
---|
2754 |
|
---|
2755 | \row
|
---|
2756 | \o \bold{Box \target Box Lengths
|
---|
2757 | Lengths}
|
---|
2758 | \o \l{#Length}{Length}\{1,4\}
|
---|
2759 | \o One to four occurrences of \l{#Length}{Length}, specifying the
|
---|
2760 | top, right, bottom, and left edges of a box,
|
---|
2761 | respectively. If the left length is not specified, it is
|
---|
2762 | taken to be the same as the right length. If the bottom
|
---|
2763 | length is not specified, is it taken to be the same as the
|
---|
2764 | top length. If the right length is not specified, it is
|
---|
2765 | taken to be the same as the top length.
|
---|
2766 |
|
---|
2767 | Examples:
|
---|
2768 |
|
---|
2769 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 83
|
---|
2770 |
|
---|
2771 | \row
|
---|
2772 | \o \bold Brush \target Brush
|
---|
2773 | \o \l{#Color}{Color} \BR
|
---|
2774 | | \l{Gradient} \BR
|
---|
2775 | | \l{PaletteRole}
|
---|
2776 | \o Specifies a Color or a Gradient or an entry in the Palette.
|
---|
2777 |
|
---|
2778 | \row
|
---|
2779 | \o \bold Color \target Color
|
---|
2780 | \o \tt{rgb(\e{r}, \e{g}, \e{b})} \BR
|
---|
2781 | | \tt{rgba(\e{r}, \e{g}, \e{b}, \e{a})} \BR
|
---|
2782 | | \tt{hsv(\e{h}, \e{s}, \e{v})} \BR
|
---|
2783 | | \tt{hsva(\e{h}, \e{s}, \e{v}, \e{a})} \BR
|
---|
2784 | | \tt{#\e{rrggbb}} \BR
|
---|
2785 | | \l{QColor::setNamedColor()}{Color Name} \BR
|
---|
2786 | \o Specifies a color as RGB (red, green, blue) or RGBA
|
---|
2787 | (red, green, blue, alpha) or HSV (hue, saturation, value) or HSVA
|
---|
2788 | (hue, saturation, value, alpha) or a named color. The \c rgb() or \c rgba()
|
---|
2789 | syntax can be used with integer values between 0 and 255, or with
|
---|
2790 | percentages. The value of s, v, and a in \c hsv() or \c hsva() must all
|
---|
2791 | be in the range 0-255; the value of h must be in the range 0-359.
|
---|
2792 |
|
---|
2793 | Examples:
|
---|
2794 |
|
---|
2795 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 84
|
---|
2796 |
|
---|
2797 | \note The RGB colors allowed are the same as those allowed with
|
---|
2798 | CSS 2.1, as listed
|
---|
2799 | \l{http://www.w3.org/TR/CSS21/syndata.html#color-units}{here}.
|
---|
2800 |
|
---|
2801 | \row
|
---|
2802 | \o \bold Font \target Font
|
---|
2803 | \o (\l{#Font Style}{Font Style} | \l{#Font Weight}{Font Weight}){0,2} \l{#Font Size}{Font Size} String
|
---|
2804 | \o Shorthand font property.
|
---|
2805 |
|
---|
2806 | \row
|
---|
2807 | \o \bold{Font \target Font Size
|
---|
2808 | Size}
|
---|
2809 | \o \l{Length}
|
---|
2810 | \o The size of a font.
|
---|
2811 |
|
---|
2812 | \row
|
---|
2813 | \o \bold{Font \target Font Style
|
---|
2814 | Style}
|
---|
2815 | \o \c normal \BR
|
---|
2816 | | \c italic \BR
|
---|
2817 | | \c oblique
|
---|
2818 | \o The style of a font.
|
---|
2819 |
|
---|
2820 | \row
|
---|
2821 | \o \bold{Font \target Font Weight
|
---|
2822 | Weight}
|
---|
2823 | \o \c normal \BR
|
---|
2824 | | \c bold \BR
|
---|
2825 | | \c 100 \BR
|
---|
2826 | | \c 200 \BR
|
---|
2827 | ... \BR
|
---|
2828 | | \c 900
|
---|
2829 | \o The weight of a font.
|
---|
2830 |
|
---|
2831 | \row
|
---|
2832 | \o \bold Gradient \target Gradient
|
---|
2833 | \o \c qlineargradient \BR
|
---|
2834 | | \c qradialgradient \BR
|
---|
2835 | | \c qconicalgradient
|
---|
2836 | \o Specifies gradient fills. There are three types of gradient fills:
|
---|
2837 |
|
---|
2838 | \list
|
---|
2839 | \o \e{Linear} gradients interpolate colors between start and
|
---|
2840 | end points.
|
---|
2841 | \o \e{Radial} gradients interpolate colors between a focal
|
---|
2842 | point and end points on a circle surrounding it.
|
---|
2843 | \o \e{Conical} gradients interpolate colors around a center
|
---|
2844 | point.
|
---|
2845 | \endlist
|
---|
2846 |
|
---|
2847 | Gradients are specified in Object Bounding Mode. Imagine the box
|
---|
2848 | in which the gradient is rendered, to have its top left corner at (0, 0)
|
---|
2849 | and its bottom right corner at (1, 1). Gradient parameters are
|
---|
2850 | then specified as percentages from 0 to 1. These values are
|
---|
2851 | extrapolated to actual box coordinates at runtime. It is possible
|
---|
2852 | specify values that lie outside the bounding box (-0.6 or 1.8, for
|
---|
2853 | instance).
|
---|
2854 |
|
---|
2855 | \warning The stops have to appear sorted in ascending order.
|
---|
2856 |
|
---|
2857 | Examples:
|
---|
2858 |
|
---|
2859 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 85
|
---|
2860 |
|
---|
2861 | \row
|
---|
2862 | \o \bold Icon \target Icon
|
---|
2863 | \o (\l{#Url}{Url} (\c disabled | \c active | \c normal | \c selected)?
|
---|
2864 | (\c on | \c off)? )*
|
---|
2865 | \o A list of url, QIcon::Mode and QIcon::State.
|
---|
2866 |
|
---|
2867 | Example:
|
---|
2868 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 86
|
---|
2869 |
|
---|
2870 | \row
|
---|
2871 | \o \bold Length \target Length
|
---|
2872 | \o \l{#Number}{Number} (\c px | \c pt | \c em | \c ex)?
|
---|
2873 | \o A number followed by a measurement unit. The CSS standard recommends
|
---|
2874 | that user agents must
|
---|
2875 | \l{http://www.w3.org/TR/CSS21/syndata.html#illegalvalues}{ignore}
|
---|
2876 | a declaration with an illegal value. In Qt, it is mandatory to
|
---|
2877 | specify measurement units. For compatibility with earlier versions
|
---|
2878 | of Qt, numbers without measurement units are treated as pixels
|
---|
2879 | in most contexts. The supported units are:
|
---|
2880 |
|
---|
2881 | \list
|
---|
2882 | \o \c px: pixels
|
---|
2883 | \o \c pt: the size of one point (i.e., 1/72 of an inch)
|
---|
2884 | \o \c em: the em width of the font (i.e., the width of 'M')
|
---|
2885 | \o \c ex: the ex width of the font (i.e., the height of 'x')
|
---|
2886 | \endlist
|
---|
2887 |
|
---|
2888 | \row
|
---|
2889 | \o \bold Number \target Number
|
---|
2890 | \o A decimal integer or a real number
|
---|
2891 | \o Examples: \c 0, \c 18, \c +127, \c -255, \c 12.34, \c -.5,
|
---|
2892 | \c 0009.
|
---|
2893 |
|
---|
2894 | \row
|
---|
2895 | \o \bold Origin \target Origin
|
---|
2896 | \o \c margin \BR
|
---|
2897 | | \c border \BR
|
---|
2898 | | \c padding \BR
|
---|
2899 | | \c content
|
---|
2900 | \o Indicates which of four rectangles to use.
|
---|
2901 |
|
---|
2902 | \list
|
---|
2903 | \o \c margin: The margin rectangle. The margin falls outside the border.
|
---|
2904 | \o \c border: The border rectangle. This is where any border is drawn.
|
---|
2905 | \o \c padding: The padding rectangle. Unlike the margins,
|
---|
2906 | padding is located inside the border.
|
---|
2907 | \o \c content: The content rectangle. This specifies where
|
---|
2908 | the actual contents go, excluding any
|
---|
2909 | padding, border, or margin.
|
---|
2910 | \endlist
|
---|
2911 |
|
---|
2912 | See also \l{The Box Model}.
|
---|
2913 |
|
---|
2914 | \row
|
---|
2915 | \o \bold PaletteRole \target PaletteRole
|
---|
2916 | \o \c alternate-base \BR
|
---|
2917 | | \c base \BR
|
---|
2918 | | \c bright-text \BR
|
---|
2919 | | \c button \BR
|
---|
2920 | | \c button-text \BR
|
---|
2921 | | \c dark \BR
|
---|
2922 | | \c highlight \BR
|
---|
2923 | | \c highlighted-text \BR
|
---|
2924 | | \c light \BR
|
---|
2925 | | \c link \BR
|
---|
2926 | | \c link-visited \BR
|
---|
2927 | | \c mid \BR
|
---|
2928 | | \c midlight \BR
|
---|
2929 | | \c shadow \BR
|
---|
2930 | | \c text \BR
|
---|
2931 | | \c window \BR
|
---|
2932 | | \c window-text \BR
|
---|
2933 | \o These values correspond the \l{QPalette::ColorRole}{Color roles}
|
---|
2934 | in the widget's QPalette.
|
---|
2935 |
|
---|
2936 | For example,
|
---|
2937 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 87
|
---|
2938 |
|
---|
2939 | \row
|
---|
2940 | \o \bold Radius \target Radius
|
---|
2941 | \o \l{#Length}{Length}\{1, 2\}
|
---|
2942 | \o One or two occurrences of \l{#Length}{Length}. If only one length is
|
---|
2943 | specified, it is used as the radius of the quarter circle
|
---|
2944 | defining the corner. If two lengths are specified, the
|
---|
2945 | first length is the horizontal radius of a quarter
|
---|
2946 | ellipse, whereas the second length is the vertical radius.
|
---|
2947 |
|
---|
2948 | \row
|
---|
2949 | \o \bold Repeat \target Repeat
|
---|
2950 | \o \c repeat-x \BR
|
---|
2951 | | \c repeat-y \BR
|
---|
2952 | | \c repeat \BR
|
---|
2953 | | \c no-repeat
|
---|
2954 | \o A value indicating the nature of repetition.
|
---|
2955 |
|
---|
2956 | \list
|
---|
2957 | \o \c repeat-x: Repeat horizontally.
|
---|
2958 | \o \c repeat-y: Repeat vertically.
|
---|
2959 | \o \c repeat: Repeat horizontally and vertically.
|
---|
2960 | \o \c no-repeat: Don't repeat.
|
---|
2961 | \endlist
|
---|
2962 |
|
---|
2963 | \row
|
---|
2964 | \o \bold Url \target Url
|
---|
2965 | \o \tt{url(\e{filename})}
|
---|
2966 | \o \tt{\e{filename}} is the name of a file on the local disk
|
---|
2967 | or stored using \l{the Qt Resource System}. Setting an
|
---|
2968 | image implicitly sets the width and height of the element.
|
---|
2969 |
|
---|
2970 | \endtable
|
---|
2971 |
|
---|
2972 | \section1 List of Pseudo-States
|
---|
2973 |
|
---|
2974 | The following pseudo-states are supported:
|
---|
2975 |
|
---|
2976 | \table 100%
|
---|
2977 | \header
|
---|
2978 | \o Pseudo-State
|
---|
2979 | \o Description
|
---|
2980 |
|
---|
2981 | \row \o \c :active \target active
|
---|
2982 | \o This state is set when the widget resides in an active window.
|
---|
2983 |
|
---|
2984 | \row
|
---|
2985 | \o \c :adjoins-item \target adjoins-item-ps
|
---|
2986 | \o This state is set when the \l{#branch-sub}{::branch} of a QTreeView
|
---|
2987 | is adjacent to an item.
|
---|
2988 |
|
---|
2989 | \row
|
---|
2990 | \o \c :alternate \target alternate-ps
|
---|
2991 | \o This state is set for every alternate row whe painting the row of
|
---|
2992 | a QAbstractItemView when QAbstractItemView::alternatingRowColors()
|
---|
2993 | is set to true.
|
---|
2994 |
|
---|
2995 | \row
|
---|
2996 | \o \c :bottom \target bottom-ps
|
---|
2997 | \o The item is positioned at the bottom. For example, a QTabBar
|
---|
2998 | that has its tabs positioned at the bottom.
|
---|
2999 |
|
---|
3000 | \row
|
---|
3001 | \o \c :checked \target checked-ps
|
---|
3002 | \o The item is checked. For example, the
|
---|
3003 | \l{QAbstractButton::checked}{checked} state of QAbstractButton.
|
---|
3004 |
|
---|
3005 | \row
|
---|
3006 | \o \c :closable \target closable-ps
|
---|
3007 | \o The items can be closed. For example, the QDockWidget has the
|
---|
3008 | QDockWidget::DockWidgetClosable feature turned on.
|
---|
3009 |
|
---|
3010 | \row
|
---|
3011 | \o \c :closed \target closed-ps
|
---|
3012 | \o The item is in the closed state. For example, an non-expanded
|
---|
3013 | item in a QTreeView
|
---|
3014 |
|
---|
3015 | \row
|
---|
3016 | \o \c :default \target default-ps
|
---|
3017 | \o The item is the default. For example, a
|
---|
3018 | \l{QPushButton::default}{default} QPushButton or a default action
|
---|
3019 | in a QMenu.
|
---|
3020 |
|
---|
3021 | \row
|
---|
3022 | \o \c :disabled \target disabled-ps
|
---|
3023 | \o The item is \l{QWidget::enabled}{disabled}.
|
---|
3024 |
|
---|
3025 | \row
|
---|
3026 | \o \c :editable \target editable-ps
|
---|
3027 | \o The QComboBox is editable.
|
---|
3028 |
|
---|
3029 | \row
|
---|
3030 | \o \c :edit-focus \target edit-focus-ps
|
---|
3031 | \o The item has edit focus (See QStyle::State_HasEditFocus). This state
|
---|
3032 | is available only for Qt Extended applications.
|
---|
3033 |
|
---|
3034 | \row
|
---|
3035 | \o \c :enabled \target enabled-ps
|
---|
3036 | \o The item is \l{QWidget::enabled}{enabled}.
|
---|
3037 |
|
---|
3038 | \row
|
---|
3039 | \o \c :exclusive \target exclusive-ps
|
---|
3040 | \o The item is part of an exclusive item group. For example, a menu
|
---|
3041 | item in a exclusive QActionGroup.
|
---|
3042 |
|
---|
3043 | \row
|
---|
3044 | \o \c :first \target first-ps
|
---|
3045 | \o The item is the first (in a list). For example, the first
|
---|
3046 | tab in a QTabBar.
|
---|
3047 |
|
---|
3048 | \row
|
---|
3049 | \o \c :flat \target flat-ps
|
---|
3050 | \o The item is flat. For example, a
|
---|
3051 | \l{QPushButton::flat}{flat} QPushButton.
|
---|
3052 |
|
---|
3053 | \row
|
---|
3054 | \o \c :floatable \target floatable-ps
|
---|
3055 | \o The items can be floated. For example, the QDockWidget has the
|
---|
3056 | QDockWidget::DockWidgetFloatable feature turned on.
|
---|
3057 |
|
---|
3058 | \row
|
---|
3059 | \o \c :focus \target focus-ps
|
---|
3060 | \o The item has \l{QWidget::hasFocus()}{input focus}.
|
---|
3061 |
|
---|
3062 | \row
|
---|
3063 | \o \c :has-children \target has-children-ps
|
---|
3064 | \o The item has children. For example, an item in a
|
---|
3065 | QTreeView that has child items.
|
---|
3066 |
|
---|
3067 | \row
|
---|
3068 | \o \c :has-siblings \target has-siblings-ps
|
---|
3069 | \o The item has siblings. For example, an item in a
|
---|
3070 | QTreeView that siblings.
|
---|
3071 |
|
---|
3072 | \row
|
---|
3073 | \o \c :horizontal \target horizontal-ps
|
---|
3074 | \o The item has horizontal orientation
|
---|
3075 |
|
---|
3076 | \row
|
---|
3077 | \o \c :hover \target hover-ps
|
---|
3078 | \o The mouse is hovering over the item.
|
---|
3079 |
|
---|
3080 | \row
|
---|
3081 | \o \c :indeterminate \target indeterminate-ps
|
---|
3082 | \o The item has indeterminate state. For example, a QCheckBox
|
---|
3083 | or QRadioButton is \l{Qt::PartiallyChecked}{partially checked}.
|
---|
3084 |
|
---|
3085 | \row
|
---|
3086 | \o \c :last \target last-ps
|
---|
3087 | \o The item is the last (in a list). For example, the last
|
---|
3088 | tab in a QTabBar.
|
---|
3089 |
|
---|
3090 | \row
|
---|
3091 | \o \c :left \target left-ps
|
---|
3092 | \o The item is positioned at the left. For example, a QTabBar
|
---|
3093 | that has its tabs positioned at the left.
|
---|
3094 |
|
---|
3095 | \row
|
---|
3096 | \o \c :maximized \target maximized-ps
|
---|
3097 | \o The item is maximized. For example, a maximized QMdiSubWindow.
|
---|
3098 |
|
---|
3099 | \row
|
---|
3100 | \o \c :middle \target middle-ps
|
---|
3101 | \o The item is in the middle (in a list). For example, a tab
|
---|
3102 | that is not in the beginning or the end in a QTabBar.
|
---|
3103 |
|
---|
3104 | \row
|
---|
3105 | \o \c :minimized \target minimized-ps
|
---|
3106 | \o The item is minimized. For example, a minimized QMdiSubWindow.
|
---|
3107 |
|
---|
3108 | \row
|
---|
3109 | \o \c :movable \target movable-ps
|
---|
3110 | \o The item can be moved around. For example, the QDockWidget has the
|
---|
3111 | QDockWidget::DockWidgetMovable feature turned on.
|
---|
3112 |
|
---|
3113 | \row
|
---|
3114 | \o \c :no-frame \target no-frame-ps
|
---|
3115 | \o The item has no frame. For example, a frameless QSpinBox
|
---|
3116 | or QLineEdit.
|
---|
3117 |
|
---|
3118 | \row
|
---|
3119 | \o \c :non-exclusive \target non-exclusive-ps
|
---|
3120 | \o The item is part of a non-exclusive item group. For example, a menu
|
---|
3121 | item in a non-exclusive QActionGroup.
|
---|
3122 |
|
---|
3123 | \row
|
---|
3124 | \o \c :off \target off-ps
|
---|
3125 | \o For items that can be toggled, this applies to items
|
---|
3126 | in the "off" state.
|
---|
3127 |
|
---|
3128 | \row
|
---|
3129 | \o \c :on \target on-ps
|
---|
3130 | \o For items that can be toggled, this applies to widgets
|
---|
3131 | in the "on" state.
|
---|
3132 |
|
---|
3133 | \row
|
---|
3134 | \o \c :only-one \target only-one-ps
|
---|
3135 | \o The item is the only one (in a list). For example, a lone tab
|
---|
3136 | in a QTabBar.
|
---|
3137 |
|
---|
3138 | \row
|
---|
3139 | \o \c :open \target open-ps
|
---|
3140 | \o The item is in the open state. For example, an expanded
|
---|
3141 | item in a QTreeView, or a QComboBox or QPushButton with
|
---|
3142 | an open menu.
|
---|
3143 |
|
---|
3144 | \row
|
---|
3145 | \o \c :next-selected \target next-selected-ps
|
---|
3146 | \o The next item (in a list) is selected. For example, the
|
---|
3147 | selected tab of a QTabBar is next to this item.
|
---|
3148 |
|
---|
3149 | \row
|
---|
3150 | \o \c :pressed \target pressed-ps
|
---|
3151 | \o The item is being pressed using the mouse.
|
---|
3152 |
|
---|
3153 | \row
|
---|
3154 | \o \c :previous-selected \target previous-selected-ps
|
---|
3155 | \o The previous item (in a list) is selected. For example, a
|
---|
3156 | tab in a QTabBar that is next to the selected tab.
|
---|
3157 |
|
---|
3158 | \row
|
---|
3159 | \o \c :read-only \target read-only-ps
|
---|
3160 | \o The item is marked read only or non-editable. For example,
|
---|
3161 | a read only QLineEdit or a non-editable QComboBox.
|
---|
3162 |
|
---|
3163 | \row
|
---|
3164 | \o \c :right \target right-ps
|
---|
3165 | \o The item is positioned at the right. For example, a QTabBar
|
---|
3166 | that has its tabs positioned at the right.
|
---|
3167 |
|
---|
3168 | \row
|
---|
3169 | \o \c :selected \target selected-ps
|
---|
3170 | \o The item is selected. For example, the selected tab in
|
---|
3171 | a QTabBar or the selected item in a QMenu.
|
---|
3172 |
|
---|
3173 | \row
|
---|
3174 | \o \c :top \target top-ps
|
---|
3175 | \o The item is positioned at the top. For example, a QTabBar
|
---|
3176 | that has its tabs positioned at the top.
|
---|
3177 |
|
---|
3178 | \row
|
---|
3179 | \o \c :unchecked \target unchecked-ps
|
---|
3180 | \o The item is
|
---|
3181 | \l{QAbstractButton::checked}{unchecked}.
|
---|
3182 |
|
---|
3183 | \row
|
---|
3184 | \o \c :vertical \target vertical-ps
|
---|
3185 | \o The item has vertical orientation.
|
---|
3186 |
|
---|
3187 | \row
|
---|
3188 | \o \c :window \target window-ps
|
---|
3189 | \o The widget is a window (i.e top level widget)
|
---|
3190 |
|
---|
3191 | \endtable
|
---|
3192 |
|
---|
3193 | \target subcontrols
|
---|
3194 | \section1 List of Sub-Controls
|
---|
3195 |
|
---|
3196 | The following subcontrols are available:
|
---|
3197 |
|
---|
3198 | \table 100%
|
---|
3199 | \header
|
---|
3200 | \o Sub-Control
|
---|
3201 | \o Description
|
---|
3202 |
|
---|
3203 | \row
|
---|
3204 | \o \c ::add-line \target add-line-sub
|
---|
3205 | \o The button to add a line of a QScrollBar.
|
---|
3206 |
|
---|
3207 | \row
|
---|
3208 | \o \c ::add-page \target add-page-sub
|
---|
3209 | \o The region between the handle (slider) and the \l{#add-line-sub}{add-line}
|
---|
3210 | of a QScrollBar.
|
---|
3211 |
|
---|
3212 | \row
|
---|
3213 | \o \c ::branch \target branch-sub
|
---|
3214 | \o The branch indicator of a QTreeView.
|
---|
3215 |
|
---|
3216 | \row
|
---|
3217 | \o \c ::chunk \target chunk-sub
|
---|
3218 | \o The progress chunk of a QProgressBar.
|
---|
3219 |
|
---|
3220 | \row
|
---|
3221 | \o \c ::close-button \target close-button-sub
|
---|
3222 | \o The close button of a QDockWidget.
|
---|
3223 |
|
---|
3224 | \row
|
---|
3225 | \o \c ::corner \target corner-sub
|
---|
3226 | \o The corner between two scrollbars in a QAbstractScrollArea
|
---|
3227 |
|
---|
3228 | \row
|
---|
3229 | \o \c ::down-arrow \target down-arrow-sub
|
---|
3230 | \o The down arrow of a QComboBox, QHeaderView (sort indicator),
|
---|
3231 | QScrollBar or QSpinBox.
|
---|
3232 |
|
---|
3233 | \row
|
---|
3234 | \o \c ::down-button \target down-button-sub
|
---|
3235 | \o The down button of a QScrollBar or a QSpinBox.
|
---|
3236 |
|
---|
3237 | \row
|
---|
3238 | \o \c ::drop-down \target drop-down-sub
|
---|
3239 | \o The drop-down button of a QComboBox.
|
---|
3240 |
|
---|
3241 | \row
|
---|
3242 | \o \c ::float-button \target float-button-sub
|
---|
3243 | \o The float button of a QDockWidget
|
---|
3244 |
|
---|
3245 | \row
|
---|
3246 | \o \c ::groove \target groove-sub
|
---|
3247 | \o The groove of a QSlider.
|
---|
3248 |
|
---|
3249 | \row
|
---|
3250 | \o \c ::indicator \target indicator-sub
|
---|
3251 | \o The indicator of a QAbstractItemView, a QCheckBox, a QRadioButton,
|
---|
3252 | a checkable QMenu item or a checkable QGroupBox.
|
---|
3253 |
|
---|
3254 | \row
|
---|
3255 | \o \c ::handle \target handle-sub
|
---|
3256 | \o The handle (slider) of a QScrollBar, a QSplitter, or a QSlider.
|
---|
3257 |
|
---|
3258 | \row
|
---|
3259 | \o \c ::icon \target icon-sub
|
---|
3260 | \o The icon of a QAbstractItemView or a QMenu.
|
---|
3261 |
|
---|
3262 | \row
|
---|
3263 | \o \c ::item \target item-sub
|
---|
3264 | \o An item of a QAbstractItemView, a QMenuBar, a QMenu, or
|
---|
3265 | a QStatusBar.
|
---|
3266 |
|
---|
3267 | \row
|
---|
3268 | \o \c ::left-arrow \target left-arrow-sub
|
---|
3269 | \o The left arrow of a QScrollBar.
|
---|
3270 |
|
---|
3271 | \row
|
---|
3272 | \o \c ::left-corner \target left-corner-sub
|
---|
3273 | \o The left corner of a QTabWidget. For example, this control can be
|
---|
3274 | used to control position the left corner widget in a QTabWidget.
|
---|
3275 |
|
---|
3276 | \row
|
---|
3277 | \o \c ::menu-arrow \target menu-arrow-sub
|
---|
3278 | \o The arrow of a QToolButton with a menu.
|
---|
3279 |
|
---|
3280 | \row
|
---|
3281 | \o \c ::menu-button \target menu-button-sub
|
---|
3282 | \o The menu button of a QToolButton.
|
---|
3283 |
|
---|
3284 | \row
|
---|
3285 | \o \c ::menu-indicator \target menu-indicator-sub
|
---|
3286 | \o The menu indicator of a QPushButton.
|
---|
3287 |
|
---|
3288 | \row
|
---|
3289 | \o \c ::right-arrow \target right-arrow-sub
|
---|
3290 | \o The right arrow of a QMenu or a QScrollBar.
|
---|
3291 |
|
---|
3292 | \row
|
---|
3293 | \o \c ::pane \target pane-sub
|
---|
3294 | \o The pane (frame) of a QTabWidget.
|
---|
3295 |
|
---|
3296 | \row
|
---|
3297 | \o \c ::right-corner \target right-corner-sub
|
---|
3298 | \o The right corner of a QTabWidget. For example, this control can be
|
---|
3299 | used to control the position the right corner widget in a QTabWidget.
|
---|
3300 |
|
---|
3301 | \row
|
---|
3302 | \o \c ::scroller \target scroller-sub
|
---|
3303 | \o The scroller of a QMenu or QTabBar.
|
---|
3304 |
|
---|
3305 | \row
|
---|
3306 | \o \c ::section \target section-sub
|
---|
3307 | \o The section of a QHeaderView.
|
---|
3308 |
|
---|
3309 | \row
|
---|
3310 | \o \c ::separator \target separator-sub
|
---|
3311 | \o The separator of a QMenu or in a QMainWindow.
|
---|
3312 |
|
---|
3313 | \row
|
---|
3314 | \o \c ::sub-line \target sub-line-sub
|
---|
3315 | \o The button to subtract a line of a QScrollBar.
|
---|
3316 |
|
---|
3317 | \row
|
---|
3318 | \o \c ::sub-page \target sub-page-sub
|
---|
3319 | \o The region between the handle (slider) and the \l{#sub-line-sub}{sub-line}
|
---|
3320 | of a QScrollBar.
|
---|
3321 |
|
---|
3322 | \row
|
---|
3323 | \o \c ::tab \target tab-sub
|
---|
3324 | \o The tab of a QTabBar or QToolBox.
|
---|
3325 |
|
---|
3326 | \row
|
---|
3327 | \o \c ::tab-bar \target tab-bar-sub
|
---|
3328 | \o The tab bar of a QTabWidget. This subcontrol exists only to
|
---|
3329 | control the position of the QTabBar inside the QTabWidget. To
|
---|
3330 | style the tabs using the \l{#tab-sub}{::tab} subcontrol.
|
---|
3331 |
|
---|
3332 | \row
|
---|
3333 | \o \c ::tear \target tear-sub
|
---|
3334 | \o The tear indicator of a QTabBar.
|
---|
3335 |
|
---|
3336 | \row
|
---|
3337 | \o \c ::tear-off \target tear-off-sub
|
---|
3338 | \o The tear-off indicator of a QMenu.
|
---|
3339 |
|
---|
3340 | \row
|
---|
3341 | \o \c ::text \target text-ps
|
---|
3342 | \o The text of a QAbstractItemView.
|
---|
3343 |
|
---|
3344 | \row
|
---|
3345 | \o \c ::title \target title-sub
|
---|
3346 | \o The title of a QGroupBox or a QDockWidget.
|
---|
3347 |
|
---|
3348 | \row
|
---|
3349 | \o \c ::up-arrow \target up-arrow-sub
|
---|
3350 | \o The up arrow of a QHeaderView (sort indicator), QScrollBar
|
---|
3351 | or a QSpinBox.
|
---|
3352 |
|
---|
3353 | \row
|
---|
3354 | \o \c ::up-button \target up-button-sub
|
---|
3355 | \o The up button of a QSpinBox.
|
---|
3356 |
|
---|
3357 | \endtable
|
---|
3358 |
|
---|
3359 | See \l{Customizing the QPushButton's Menu Indicator Sub-Control}
|
---|
3360 | for an example of how to customize a subcontrol.
|
---|
3361 | */
|
---|
3362 |
|
---|
3363 | /*!
|
---|
3364 | \page stylesheet-examples.html
|
---|
3365 | \contentspage {Qt Style Sheet}{Contents}
|
---|
3366 | \previouspage Qt Style Sheets Reference
|
---|
3367 | \title Qt Style Sheets Examples
|
---|
3368 |
|
---|
3369 | \tableofcontents
|
---|
3370 | \section1 Style Sheet Usage
|
---|
3371 |
|
---|
3372 | We will now see a few examples to get started with using Qt Style Sheets.
|
---|
3373 |
|
---|
3374 | \section2 Customizing the Foreground and Background Colors
|
---|
3375 |
|
---|
3376 | Let's start by setting yellow as the background color of all
|
---|
3377 | \l{QLineEdit}s in an application. This could be achieved like
|
---|
3378 | this:
|
---|
3379 |
|
---|
3380 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 88
|
---|
3381 |
|
---|
3382 | If we want the property to apply only to the \l{QLineEdit}s that are
|
---|
3383 | children (or grandchildren or grand-grandchildren) of a specific dialog,
|
---|
3384 | we would rather do this:
|
---|
3385 |
|
---|
3386 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 89
|
---|
3387 |
|
---|
3388 | If we want the property to apply only to one specific QLineEdit,
|
---|
3389 | we can give it a name using QObject::setObjectName() and use an
|
---|
3390 | ID Selector to refer to it:
|
---|
3391 |
|
---|
3392 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 90
|
---|
3393 |
|
---|
3394 | Alternatively, we can set the
|
---|
3395 | \l{Qt Style Sheets Reference#background-prop}{background-color} property directly on the
|
---|
3396 | QLineEdit, omitting the selector:
|
---|
3397 |
|
---|
3398 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 91
|
---|
3399 |
|
---|
3400 | To ensure a good contrast, we should also specify a suitable
|
---|
3401 | color for the text:
|
---|
3402 |
|
---|
3403 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 92
|
---|
3404 |
|
---|
3405 | It might be a good idea to change the colors used for selected
|
---|
3406 | text as well:
|
---|
3407 |
|
---|
3408 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 93
|
---|
3409 |
|
---|
3410 |
|
---|
3411 | \section2 Customizing Using Dynamic Properties
|
---|
3412 |
|
---|
3413 | There are many situations where we need to present a form that
|
---|
3414 | has mandatory fields. To indicate to the user that the field is
|
---|
3415 | mandatory, one effective (albeit esthetically dubious) solution
|
---|
3416 | is to use yellow as the background color for those fields. It
|
---|
3417 | turns out this is very easy to implement using Qt Style Sheets.
|
---|
3418 | First, we would use the following application-wide style sheet:
|
---|
3419 |
|
---|
3420 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 94
|
---|
3421 |
|
---|
3422 | This means that every widget whose \c mandatoryField Qt property
|
---|
3423 | is set to true would have a yellow background.
|
---|
3424 |
|
---|
3425 | Then, for each mandatory field widget, we would simply create a
|
---|
3426 | \c mandatoryField property on the fly and set it to true. For
|
---|
3427 | example:
|
---|
3428 |
|
---|
3429 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 95
|
---|
3430 |
|
---|
3431 | \section2 Customizing a QPushButton Using the Box Model
|
---|
3432 |
|
---|
3433 | This time, we will show how to create a red QPushButton. This
|
---|
3434 | QPushButton would presumably be connected to a very destructive
|
---|
3435 | piece of code.
|
---|
3436 |
|
---|
3437 | First, we are tempted to use this style sheet:
|
---|
3438 |
|
---|
3439 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 96
|
---|
3440 |
|
---|
3441 | However, the result is a boring, flat button with no borders:
|
---|
3442 |
|
---|
3443 | \image stylesheet-redbutton1.png A flat red button
|
---|
3444 |
|
---|
3445 | What happened is this:
|
---|
3446 |
|
---|
3447 | \list
|
---|
3448 | \o We have made a request that cannot be satisfied using the
|
---|
3449 | native styles alone (e.g., the Windows XP theme engine doesn't
|
---|
3450 | let us specify the background color of a button).
|
---|
3451 | \o Therefore, the button is rendered using style sheets.
|
---|
3452 | \o We haven't specified any values for
|
---|
3453 | \l{Qt Style Sheets Reference#border-width-prop}{border-width} and
|
---|
3454 | \l{Qt Style Sheets Reference#border-style-prop}{border-style}, so by default we obtain
|
---|
3455 | a 0-pixel wide border of style \c none.
|
---|
3456 | \endlist
|
---|
3457 |
|
---|
3458 | Let's improve the situation by specifying a border:
|
---|
3459 |
|
---|
3460 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 97
|
---|
3461 |
|
---|
3462 | \image stylesheet-redbutton2.png A red button with a beige border
|
---|
3463 |
|
---|
3464 | Things look already a lot better. But the button looks a bit
|
---|
3465 | cramped. Let's specify some spacing between the border and the
|
---|
3466 | text using the \l{Qt Style Sheets Reference#padding-prop}{padding}. Additionally, we will
|
---|
3467 | enforce a minimum width, round the corners, and specify a larger
|
---|
3468 | font to make the button look nicer:
|
---|
3469 |
|
---|
3470 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 98
|
---|
3471 |
|
---|
3472 | \image stylesheet-redbutton3.png A red button with a round beige border and big, bold text
|
---|
3473 |
|
---|
3474 | The only issue remaining is that the button doesn't react when we
|
---|
3475 | press it. We can fix this by specifying a slightly different
|
---|
3476 | background color and use a different border style.
|
---|
3477 |
|
---|
3478 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 99
|
---|
3479 |
|
---|
3480 | \section2 Customizing the QPushButton's Menu Indicator Sub-Control
|
---|
3481 |
|
---|
3482 | Subcontrols give access to the sub-elements of a widget. For
|
---|
3483 | example, a QPushButton associated with a menu (using
|
---|
3484 | QPushButton::setMenu()) has a menu indicator. Let's customize
|
---|
3485 | the menu indicator for the red push button:
|
---|
3486 |
|
---|
3487 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 100
|
---|
3488 |
|
---|
3489 | By default, the menu indicator is located at the bottom-right
|
---|
3490 | corner of the padding rectangle. We can change this by specifying
|
---|
3491 | \l{Qt Style Sheets Reference#subcontrol-position-prop}{subcontrol-position} and
|
---|
3492 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin} to anchor the
|
---|
3493 | indicator differently. We can also use \l{Qt Style Sheets Reference#top-prop}{top} and
|
---|
3494 | \l{Qt Style Sheets Reference#left-prop}{left} to move the indicator by a few pixels. For
|
---|
3495 | example:
|
---|
3496 |
|
---|
3497 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 101
|
---|
3498 |
|
---|
3499 | This positions the \c myindicator.png to the center right of the
|
---|
3500 | QPushButton's \l{Qt Style Sheets Reference#padding-prop}{padding} rectangle (see
|
---|
3501 | \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin} for more
|
---|
3502 | information).
|
---|
3503 |
|
---|
3504 | \section2 Complex Selector Example
|
---|
3505 |
|
---|
3506 | Since red seems to be our favorite color, let's make the text in
|
---|
3507 | QLineEdit red by setting the following application-wide
|
---|
3508 | stylesheet:
|
---|
3509 |
|
---|
3510 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 102
|
---|
3511 |
|
---|
3512 | However, we would like to give a visual indication that a
|
---|
3513 | QLineEdit is read-only by making it appear gray:
|
---|
3514 |
|
---|
3515 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 103
|
---|
3516 |
|
---|
3517 | At some point, our design team comes with the requirement that
|
---|
3518 | all \l{QLineEdit}s in the registration form (with the
|
---|
3519 | \l{QObject::objectName}{object name} \c registrationDialog) to be
|
---|
3520 | brown:
|
---|
3521 |
|
---|
3522 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 104
|
---|
3523 |
|
---|
3524 | A few UI design meetings later, we decide that all our
|
---|
3525 | \l{QDialog}s should have brown colored \l{QLineEdit}s:
|
---|
3526 |
|
---|
3527 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 105
|
---|
3528 |
|
---|
3529 | Quiz: What happens if we have a read-only QLineEdit in a QDialog?
|
---|
3530 | [Hint: The \l{The Style Sheet Syntax#Conflict Resolution}{Conflict Resolution} section above explains
|
---|
3531 | what happens in cases like this.]
|
---|
3532 |
|
---|
3533 | \section1 Customizing specific widgets
|
---|
3534 |
|
---|
3535 | This section provides examples to customize specific widgets using Style Sheets.
|
---|
3536 |
|
---|
3537 | \section2 Customizing QAbstractScrollArea
|
---|
3538 |
|
---|
3539 | The background of any QAbstractScrollArea (Item views, QTextEdit
|
---|
3540 | and QTextBrowser) can be set using the background properties. For example,
|
---|
3541 | to set a background-image that scrolls with the scroll bar:
|
---|
3542 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 106
|
---|
3543 |
|
---|
3544 | If the background-image is to be fixed with the viewport:
|
---|
3545 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 107
|
---|
3546 |
|
---|
3547 | \section2 Customizing QCheckBox
|
---|
3548 |
|
---|
3549 | Styling of a QCheckBox is almost indentical to styling a QRadioButton. The
|
---|
3550 | main difference is that a tristate QCheckBox has an indeterminate state.
|
---|
3551 |
|
---|
3552 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 108
|
---|
3553 |
|
---|
3554 | \section2 Customizing QComboBox
|
---|
3555 |
|
---|
3556 | We will look at an example where the drop down button of a QComboBox
|
---|
3557 | appears "merged" with the combo box frame.
|
---|
3558 |
|
---|
3559 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 109
|
---|
3560 |
|
---|
3561 | The pop-up of the QComboBox is a QAbstractItemView and is styled using
|
---|
3562 | the descendant selector:
|
---|
3563 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 110
|
---|
3564 |
|
---|
3565 | \section2 Customizing QDockWidget
|
---|
3566 |
|
---|
3567 | The title bar and the buttons of a QDockWidget can be customized as
|
---|
3568 | follows:
|
---|
3569 |
|
---|
3570 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 111
|
---|
3571 |
|
---|
3572 | If one desires to move the dock widget buttons to the left, the following
|
---|
3573 | style sheet can be used:
|
---|
3574 |
|
---|
3575 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 112
|
---|
3576 |
|
---|
3577 | \note To customize the separator (resize handle) of a QDockWidget,
|
---|
3578 | use QMainWindow::separator.
|
---|
3579 |
|
---|
3580 | \section2 Customizing QFrame
|
---|
3581 |
|
---|
3582 | A QFrame is styled using the \l{The Box Model}.
|
---|
3583 |
|
---|
3584 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 113
|
---|
3585 |
|
---|
3586 | \section2 Customizing QGroupBox
|
---|
3587 |
|
---|
3588 | Let us look at an example that moves the QGroupBox's title to
|
---|
3589 | the center.
|
---|
3590 |
|
---|
3591 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 114
|
---|
3592 |
|
---|
3593 | For a checkable QGroupBox, use the \{#indicator-sub}{::indicator} subcontrol
|
---|
3594 | and style it exactly like a QCheckBox (i.e)
|
---|
3595 |
|
---|
3596 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 115
|
---|
3597 |
|
---|
3598 | \section2 Customizing QHeaderView
|
---|
3599 |
|
---|
3600 | QHeaderView is customized as follows:
|
---|
3601 |
|
---|
3602 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 116
|
---|
3603 |
|
---|
3604 | \section2 Customizing QLineEdit
|
---|
3605 |
|
---|
3606 | The frame of a QLineEdit is styled using the \l{The Box Model}. To
|
---|
3607 | create a line edit with rounded corners, we can set:
|
---|
3608 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 117
|
---|
3609 |
|
---|
3610 | The password character of line edits that have QLineEdit::Password
|
---|
3611 | echo mode can be set using:
|
---|
3612 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 118
|
---|
3613 |
|
---|
3614 | The background of a read only QLineEdit can be modified as below:
|
---|
3615 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 119
|
---|
3616 |
|
---|
3617 | \section2 Customizing QListView
|
---|
3618 |
|
---|
3619 | The background color of alternating rows can be customized using the following
|
---|
3620 | style sheet:
|
---|
3621 |
|
---|
3622 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 120
|
---|
3623 |
|
---|
3624 | To provide a special background when you hover over items, we can use the
|
---|
3625 | \l{item-sub}{::item} subcontrol. For example,
|
---|
3626 |
|
---|
3627 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 121
|
---|
3628 |
|
---|
3629 | \section2 Customizing QMainWindow
|
---|
3630 |
|
---|
3631 | The separator of a QMainWindow can be styled as follows:
|
---|
3632 |
|
---|
3633 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 122
|
---|
3634 |
|
---|
3635 | \section2 Customizing QMenu
|
---|
3636 |
|
---|
3637 | Individual items of a QMenu are styled using the 'item' subcontrol as
|
---|
3638 | follows:
|
---|
3639 |
|
---|
3640 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 123
|
---|
3641 |
|
---|
3642 | For a more advanced customization, use a style sheet as follows:
|
---|
3643 |
|
---|
3644 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 124
|
---|
3645 |
|
---|
3646 | \section2 Customizing QMenuBar
|
---|
3647 |
|
---|
3648 | QMenuBar is styled as follows:
|
---|
3649 |
|
---|
3650 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 125
|
---|
3651 |
|
---|
3652 | \section2 Customizing QProgressBar
|
---|
3653 |
|
---|
3654 | The QProgressBar's \l{stylesheet-reference.html#border-prop}{border},
|
---|
3655 | \l{stylesheet-reference.html#chunk-sub}{chunk}, and
|
---|
3656 | \l{stylesheet-reference.html#text-align-prop}{text-align} can be customized using
|
---|
3657 | style sheets. However, if one property or sub-control is customized,
|
---|
3658 | all the other properties or sub-controls must be customized as well.
|
---|
3659 |
|
---|
3660 | \image progressBar-stylesheet.png
|
---|
3661 |
|
---|
3662 | For example, we change the \l{stylesheet-reference.html#border-prop}
|
---|
3663 | {border} to grey and the \l{stylesheet-reference.html#chunk-sub}{chunk}
|
---|
3664 | to cerulean.
|
---|
3665 |
|
---|
3666 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 126
|
---|
3667 |
|
---|
3668 | This leaves the \l{stylesheet-reference.html#text-align-prop}
|
---|
3669 | {text-align}, which we customize by positioning the text in the center of
|
---|
3670 | the progress bar.
|
---|
3671 |
|
---|
3672 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 127
|
---|
3673 |
|
---|
3674 | A \l{stylesheet-reference.html#margin-prop}{margin} can be included to
|
---|
3675 | obtain more visible chunks.
|
---|
3676 |
|
---|
3677 | \image progressBar2-stylesheet.png
|
---|
3678 |
|
---|
3679 | In the screenshot above, we use a
|
---|
3680 | \l{stylesheet-reference.html#margin-prop}{margin} of 0.5 pixels.
|
---|
3681 |
|
---|
3682 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 128
|
---|
3683 |
|
---|
3684 | \section2 Customizing QPushButton
|
---|
3685 |
|
---|
3686 | A QPushButton is styled as follows:
|
---|
3687 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 129
|
---|
3688 |
|
---|
3689 | For a QPushButton with a menu, use the
|
---|
3690 | \l{Qt Style Sheets Reference#menu-indicator-sub}{::menu-indicator}
|
---|
3691 | subcontrol.
|
---|
3692 |
|
---|
3693 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 130
|
---|
3694 |
|
---|
3695 | Checkable QPushButton have the \l{Qt Style Sheets Reference#checked-ps}
|
---|
3696 | {:checked} pseudo state set.
|
---|
3697 |
|
---|
3698 | \section2 Customizing QRadioButton
|
---|
3699 |
|
---|
3700 | The indicator of a QRadioButton can be changed using:
|
---|
3701 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 131
|
---|
3702 |
|
---|
3703 | \section2 Customizing QScrollBar
|
---|
3704 |
|
---|
3705 | The QScrollBar can be styled using its subcontrols like
|
---|
3706 | \l{stylesheet-reference.html#handle-sub}{handle},
|
---|
3707 | \l{stylesheet-reference.html#add-line-sub}{add-line},
|
---|
3708 | \l{stylesheet-reference.html#sub-line-sub}{sub-line}, and so on. Note that
|
---|
3709 | if one property or sub-control is customized, all the other properties or
|
---|
3710 | sub-controls must be customized as well.
|
---|
3711 |
|
---|
3712 | \image stylesheet-scrollbar1.png
|
---|
3713 |
|
---|
3714 | The scroll bar above has been styled in aquamarine with a solid grey
|
---|
3715 | border.
|
---|
3716 |
|
---|
3717 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 132
|
---|
3718 |
|
---|
3719 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 133
|
---|
3720 |
|
---|
3721 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 134
|
---|
3722 |
|
---|
3723 | The \l{stylesheet-reference.html#left-arrow-sub}{left-arrow} and
|
---|
3724 | \l{stylesheet-reference.html#right-arrow-sub}{right-arrow} have a solid grey
|
---|
3725 | border with a white background. As an alternative, you could also embed the
|
---|
3726 | image of an arrow.
|
---|
3727 |
|
---|
3728 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 135
|
---|
3729 |
|
---|
3730 | If you want the scroll buttons of the scroll bar to be placed together
|
---|
3731 | (instead of the edges) like on Mac OS X, you can use the following
|
---|
3732 | stylesheet:
|
---|
3733 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 136
|
---|
3734 |
|
---|
3735 | The scroll bar using the above stylesheet looks like this:
|
---|
3736 | \image stylesheet-scrollbar2.png
|
---|
3737 |
|
---|
3738 |
|
---|
3739 | To customize a vertical scroll bar use a style sheet similar to the following:
|
---|
3740 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 137
|
---|
3741 |
|
---|
3742 | \section2 Customizing QSizeGrip
|
---|
3743 |
|
---|
3744 | QSizeGrip is usually styled by just setting an image.
|
---|
3745 |
|
---|
3746 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 138
|
---|
3747 |
|
---|
3748 | \section2 Customizing QSlider
|
---|
3749 |
|
---|
3750 | You can style horizontal slider as below:
|
---|
3751 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 139
|
---|
3752 |
|
---|
3753 | If you want to change the color of the slider parts before and after the handle, you can use the add-page
|
---|
3754 | and sub-page subcontrols. For example, for a vertical slider:
|
---|
3755 |
|
---|
3756 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 140
|
---|
3757 |
|
---|
3758 | \section2 Customizing QSpinBox
|
---|
3759 |
|
---|
3760 | QSpinBox can be completely customized as below (the style sheet has commentary inline):
|
---|
3761 |
|
---|
3762 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 141
|
---|
3763 |
|
---|
3764 |
|
---|
3765 | \section2 Customizing QSplitter
|
---|
3766 |
|
---|
3767 | A QSplitter derives from a QFrame and hence can be styled like a QFrame.
|
---|
3768 | The grip or the handle is customized using the
|
---|
3769 | \l{Qt Style Sheets Reference#handle-sub}{::handle} subcontrol.
|
---|
3770 |
|
---|
3771 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 142
|
---|
3772 |
|
---|
3773 | \section2 Customizing QStatusBar
|
---|
3774 |
|
---|
3775 | We can provide a background for the status bar and a border for items
|
---|
3776 | inside the status bar as follows:
|
---|
3777 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 143
|
---|
3778 |
|
---|
3779 | Note that widgets that have been added to the QStatusBar can be styled
|
---|
3780 | using the descendant declaration (i.e)
|
---|
3781 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 144
|
---|
3782 |
|
---|
3783 | \section2 Customizing QTabWidget and QTabBar
|
---|
3784 |
|
---|
3785 | \image tabWidget-stylesheet1.png
|
---|
3786 |
|
---|
3787 | For the screenshot above, we need a stylesheet as follows:
|
---|
3788 |
|
---|
3789 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 145
|
---|
3790 |
|
---|
3791 | Often we require the tabs to overlap to look like below:
|
---|
3792 | \image tabWidget-stylesheet2.png
|
---|
3793 |
|
---|
3794 | For a tab widget that looks like above, we make use of
|
---|
3795 | \l{http://www.communitymx.com/content/article.cfm?cid=B0029}
|
---|
3796 | {negative margins}. The resulting stylesheet looks like this:
|
---|
3797 |
|
---|
3798 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 146
|
---|
3799 |
|
---|
3800 | To move the tab bar to the center (as below), we require the following stylesheet:
|
---|
3801 | \image tabWidget-stylesheet3.png
|
---|
3802 |
|
---|
3803 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 147
|
---|
3804 |
|
---|
3805 | The tear indicator and the scroll buttons can be further customized as follows:
|
---|
3806 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 148
|
---|
3807 |
|
---|
3808 | \section2 Customizing QTableView
|
---|
3809 |
|
---|
3810 | Suppose we'd like our selected item in QTableView to have bubblegum pink
|
---|
3811 | fade to white as its background.
|
---|
3812 |
|
---|
3813 | \image tableWidget-stylesheet.png
|
---|
3814 |
|
---|
3815 | This is possible with the
|
---|
3816 | \l{stylesheet-reference.html#selection-background-color-prop}
|
---|
3817 | {selection-background-color} property and the syntax required is:
|
---|
3818 |
|
---|
3819 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 149
|
---|
3820 |
|
---|
3821 | The corner widget can be customized using the following style sheet
|
---|
3822 |
|
---|
3823 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 150
|
---|
3824 |
|
---|
3825 | \section2 Customizing QToolBar
|
---|
3826 |
|
---|
3827 | The background and the handle of a QToolBar is customized as below:
|
---|
3828 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 151
|
---|
3829 |
|
---|
3830 | \section2 Customizing QToolBox
|
---|
3831 |
|
---|
3832 | The tabs of the QToolBox are customized using the 'tab' subcontrol.
|
---|
3833 |
|
---|
3834 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 152
|
---|
3835 |
|
---|
3836 | \section2 Customizing QToolButton
|
---|
3837 |
|
---|
3838 | There are three types of QToolButtons.
|
---|
3839 | \list
|
---|
3840 | \i The QToolButton has no menu. In this case, the QToolButton is styled
|
---|
3841 | exactly like QPushButton. See
|
---|
3842 | \l{#Customizing QPushButton}{Customizing QPushButton} for an
|
---|
3843 | example.
|
---|
3844 |
|
---|
3845 | \i The QToolButton has a menu and has the QToolButton::popupMode set to
|
---|
3846 | QToolButton::DelayedPopup or QToolButton::InstantPopup. In this case,
|
---|
3847 | the QToolButton is styled exactly like a QPushButton with a menu.
|
---|
3848 | See \l{#Customizing QPushButton}{Customizing QPushButton} for an
|
---|
3849 | example of the usage of the menu-indicator pseudo state.
|
---|
3850 |
|
---|
3851 | \i The QToolButton has its QToolButton::popupMode set to
|
---|
3852 | QToolButton::MenuButtonPopup. In this case, we style it as follows:
|
---|
3853 | \endlist
|
---|
3854 |
|
---|
3855 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 153
|
---|
3856 |
|
---|
3857 |
|
---|
3858 | \section2 Customizing QToolTip
|
---|
3859 |
|
---|
3860 | QToolTip is customized exactly like a QLabel. In addition, for platforms
|
---|
3861 | that support it, the opacity property may be set to adjust the opacity.
|
---|
3862 |
|
---|
3863 | For example,
|
---|
3864 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 154
|
---|
3865 |
|
---|
3866 | \section2 Customizing QTreeView
|
---|
3867 |
|
---|
3868 | The background color of alternating rows can be customized using the following
|
---|
3869 | style sheet:
|
---|
3870 |
|
---|
3871 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 155
|
---|
3872 |
|
---|
3873 | To provide a special background when you hover over items, we can use the
|
---|
3874 | \l{item-sub}{::item} subcontrol. For example,
|
---|
3875 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 156
|
---|
3876 |
|
---|
3877 | The branches of a QTreeView are styled using the
|
---|
3878 | \l{Qt Style Sheets Reference#branch-sub}{::branch} subcontrol. The
|
---|
3879 | following stylesheet color codes the various states when drawing
|
---|
3880 | a branch.
|
---|
3881 |
|
---|
3882 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 157
|
---|
3883 |
|
---|
3884 | Colorful, though it is, a more useful example can be made using the
|
---|
3885 | following images:
|
---|
3886 |
|
---|
3887 | \table
|
---|
3888 | \row
|
---|
3889 | \o \inlineimage stylesheet-vline.png
|
---|
3890 | \o \inlineimage stylesheet-branch-more.png
|
---|
3891 | \o \inlineimage stylesheet-branch-end.png
|
---|
3892 | \o \inlineimage stylesheet-branch-closed.png
|
---|
3893 | \o \inlineimage stylesheet-branch-open.png
|
---|
3894 | \row
|
---|
3895 | \o vline.png
|
---|
3896 | \o branch-more.png
|
---|
3897 | \o branch-end.png
|
---|
3898 | \o branch-closed.png
|
---|
3899 | \o branch-open.png
|
---|
3900 | \endtable
|
---|
3901 |
|
---|
3902 | \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 158
|
---|
3903 |
|
---|
3904 | The resulting tree view looks like this:
|
---|
3905 |
|
---|
3906 | \image stylesheet-treeview.png
|
---|
3907 |
|
---|
3908 | \sa {Style Sheet Example}, {Supported HTML Subset}, QStyle
|
---|
3909 |
|
---|
3910 |
|
---|
3911 | \section1 Common mistakes
|
---|
3912 |
|
---|
3913 | This section lists some common mistakes when using stylesheets.
|
---|
3914 |
|
---|
3915 | \section2 QPushButton and images
|
---|
3916 |
|
---|
3917 | When styling a QPushButton, it is often desirable to use an image as the
|
---|
3918 | button graphic. It is common to try the
|
---|
3919 | \l{Qt Style Sheets Reference#background-image-prop}{background-image}
|
---|
3920 | property,
|
---|
3921 | but this has a number of drawbacks: For instance, the background will
|
---|
3922 | often appear hidden behind the button decoration, because it is not
|
---|
3923 | considered a background. In addition, if the button is resized, the
|
---|
3924 | entire background will be stretched or tiled, which does not
|
---|
3925 | always look good.
|
---|
3926 |
|
---|
3927 | It is better to use the
|
---|
3928 | \l{Qt Style Sheets Reference#border-image-prop}{border-image}
|
---|
3929 | property, as it will always display the image,
|
---|
3930 | regardless of the background (you can combine it with a background if it
|
---|
3931 | has alpha values in it), and it has special settings to deal with button
|
---|
3932 | resizing.
|
---|
3933 |
|
---|
3934 | Consider the following snippet:
|
---|
3935 |
|
---|
3936 | \snippet doc/src/snippets/stylesheet/common-mistakes.cpp 1
|
---|
3937 |
|
---|
3938 | This will produce a button looking like this:
|
---|
3939 |
|
---|
3940 | \image stylesheet-border-image-normal.png
|
---|
3941 |
|
---|
3942 | The numbers after the url gives the top, right, bottom and left number of
|
---|
3943 | pixels, respectively. These numbers correspond to the border and should not
|
---|
3944 | stretch when the size changes.
|
---|
3945 | Whenever you resize the button, the middle part of the image will stretch
|
---|
3946 | in both directions, while the pixels specified in the stylesheet
|
---|
3947 | will not. This makes the borders of the button look more natural, like
|
---|
3948 | this:
|
---|
3949 |
|
---|
3950 | \table
|
---|
3951 | \row
|
---|
3952 | \o \inlineimage stylesheet-border-image-stretched.png
|
---|
3953 | \row
|
---|
3954 | \o With borders
|
---|
3955 | \endtable
|
---|
3956 |
|
---|
3957 | \table
|
---|
3958 | \row
|
---|
3959 | \o \inlineimage stylesheet-border-image-wrong.png
|
---|
3960 | \row
|
---|
3961 | \o Without borders
|
---|
3962 | \endtable
|
---|
3963 |
|
---|
3964 | */
|
---|