Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtquickcontrols-customize.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page qtquickcontrols-customize.html
6 \keyword Customizing Qt Quick Controls 2
7 \title Customizing Qt Quick Controls
8 \brief A set of UI controls to create user interfaces in Qt Quick
9
10 Qt Quick Controls consist of a hierarchy (tree) of items. In order to
11 provide a custom look and feel, the default QML implementation of each
12 item can be replaced with a custom one.
13
14 \section1 Customizing a Control
15
16 Sometimes you'll want to create a "one-off" look for a specific part of
17 your UI, and use a complete style everywhere else. Perhaps you're happy
18 with the style you're using, but there's a certain button that has some
19 special significance.
20
21 The first way to create this button is to simply define it in-place,
22 wherever it is needed. For example, perhaps you're not satisfied with the
23 Basic style's Button having square corners. To make them rounded, you
24 can override the \l {Control::}{background} item and set the radius
25 property of Rectangle:
26
27 \include customize-button-background.qdocinc file
28
29 \note as the different items that make up a control in any given style are
30 designed to work together, it may be necessary to override other items to
31 get the look you're after. In addition, not all styles can be customized.
32 See the note in \l {Customization Reference} for more information.
33
34 The second way to create the button is good if you plan to use your rounded
35 button in several places. It involves moving the code into its own QML file
36 within your project.
37
38 For this approach, we'll copy the background code from the Basic style's
39 \c Button.qml. This file can be found in the following path in your Qt
40 installation:
41
42 \c {$QTDIR/qml/QtQuick/Controls/Basic/Button.qml}
43
44 After doing that, we'll simply add the following line:
45
46 \code
47 radius: 4
48 \endcode
49
50 To avoid confusion with the controls in the
51 module itself, we'll call the file \c MyButton.qml. To use the control in
52 your application, refer to it by its filename:
53
54 \qml
55 import QtQuick.Controls
56
57 ApplicationWindow {
58 MyButton {
59 text: qsTr("A Special Button")
60 }
61 }
62 \endqml
63
64 The third way to create the button is a bit more structured, both in terms
65 of where the file sits in the file system and how it is used in QML. First,
66 copy an existing file as you did above, but this time, put it into a
67 subfolder in your project named (for example) \c controls. To use the
68 control, first import the folder into a namespace:
69
70 \qml
71 import QtQuick.Controls
72 import "controls" as MyControls
73
74 ApplicationWindow {
75 MyControls.Button {
76 text: qsTr("A Special Button")
77 }
78 }
79 \endqml
80
81 As you now have the \c MyControls namespace, you can name the controls after
82 their actual counterparts in the Qt Quick Controls module. You can repeat
83 this process for any control that you wish to add.
84
85 An added benefit of these three methods is that it's not necessary to
86 implement the template from scratch.
87
88 \note the three approaches mentioned here do not work for customizing the
89 attached \l ToolTip, as that is a shared item created internally. To do
90 a one-off customization of a \c ToolTip, see \l {Custom Tool Tips}. To
91 customize the attached \c ToolTip, it must be provided as part of
92 \l {Creating a Custom Style}{your own style}.
93
94 \section1 Creating a Custom Style
95
96 There are several ways to go about creating your own styles. Below, we'll
97 explain the various approaches.
98
99 \section2 Definition of a Style
100
101 In Qt Quick Controls, a style is essentially a set of QML files within a
102 single directory. There are four requirements for a style to be
103 \l {Using Styles in Qt Quick Controls}{usable}:
104
105 \list
106 \li At least one QML file whose name matches a control (for example,
107 \c Button.qml) must exist.
108 \li Each QML file must contain the relevant type from the \l {Qt Quick Templates 2}
109 {QtQuick.Templates} import as the root item. For example,
110 Button.qml must contain a Button template as its root item.
111
112 If we instead used the corresponding type from the \l {Qt Quick Controls}
113 {QtQuick.Controls} import as we did in the previous section, it would not work:
114 the control we were defining would try to derive from itself.
115 \li A \l {Module Definition qmldir Files}{qmldir} file must exist alongside
116 the QML file(s). Below is an example of a simple \c qmldir file for a style that
117 provides a button:
118
119 \badcode
120 module MyStyle
121 Button 2.15 Button.qml
122 \endcode
123
124 If you're using \l {Compile-Time Style Selection}{compile-time style
125 selection}, the qmldir should also import the fallback style:
126
127 \badcode
128 # ...
129 import QtQuick.Controls.Basic auto
130 \endcode
131
132 This can also be done for \l {Run-Time Style Selection}{run-time style selection}
133 instead of using, for example, \l QQuickStyle::setFallbackStyle().
134
135 The directory structure for such a style looks like this:
136
137 \badcode
138 MyStyle
139 ├─── Button.qml
140 └─── qmldir
141 \endcode
142 \li The files must be in a directory that is findable via the \l[QtQml]{QML Import Path}.
143
144 For example, if the path to \e MyStyle directory mentioned above was
145 \c /home/user/MyApp/MyStyle, then \c /home/user/MyApp must be added to
146 the QML import path.
147
148 To \l {Using Styles in Qt Quick Controls}{use} \e MyStyle in \e MyApp,
149 refer to it by name:
150
151 \list
152 \li \c {./MyApp -style MyStyle}
153 \endlist
154
155 The style name must match the casing of the style directory; passing
156 \e mystyle or \e MYSTYLE is not supported.
157 \endlist
158
159 By default, the styling system uses the Basic style as a fallback for
160 controls that aren't implemented. To customize or extend any other built-in
161 style, it is possible to specify a different fallback style using
162 \l[QtQuickControls2]{QQuickStyle}.
163
164 What this means is that you can implement as many controls as you like for
165 your custom style, and place them almost anywhere. It also allows users to
166 create their own styles for your application.
167
168 \section3 Previewing Custom Styles in Qt Quick Designer
169
170 Using the approach above, it is possible to preview a custom style
171 in Qt Quick Designer. In order to do so,
172 ensure that the project has a
173 \l {Qt Quick Controls Configuration File}{qtquickcontrols2.conf} file,
174 and that the following entry exists:
175
176 \badcode
177 [Controls]
178 Style=MyStyle
179 \endcode
180
181 For more information, take a look at the
182 \l {Qt Quick Controls - Flat Style}{Flat Style example}.
183
184 \section2 Style-specific C++ Extensions
185
186 Sometimes you may need to use C++ to extend your custom style. There are two
187 ways to expose such types to QML:
188
189 \list
190 \li If the style that uses the type is the only style used by an application,
191 it's enough to register it with the QML engine via qmlRegisterType():
192
193 \code
194 qmlRegisterType<ACoolCppItem>("MyApp", 1, 0, "ACoolItem");
195 \endcode
196
197 See \l {Using C++ Data From QML} for more information about this.
198 \li If the style that uses the type is one of many styles used by an
199 application, it may be better to only register it when necessary. This
200 is the point at which it would make sense to implement your own
201 \l {Creating C++ Plugins for QML}{QML plugin}.
202
203 Using a plugin as part of your style is not that much different from
204 using a set of QML files. The only difference is that the plugin and
205 its \c qmldir file must be present in the same directory as the QML
206 files.
207 \endlist
208
209 \section3 Considerations for custom styles
210
211 When implementing your own style and customizing controls, there are some
212 points to keep in mind to ensure that your application is as performant as
213 possible.
214
215 \section4 Avoid assigning an id to styles' implementations of item delegates
216
217 As explained in \l {Definition of a Style}, when you implement your
218 own style for a control, you start off with the relevant template for
219 that control. For example, a style's \c Button.qml will be structured
220 similarly to this:
221
222 \qml
223 T.Button {
224 // ...
225
226 background: Rectangle {
227 // ...
228 }
229
230 contentItem: Text {
231 // ...
232 }
233
234 // ...
235 }
236 \endqml
237
238 When you use a Button in your application, the \c background and
239 \c contentItem items will be created and parented to the root \c Button
240 item:
241
242 \qml
243 // Creates the Button root item, the Rectangle background,
244 // and the Text contentItem.
245 Button {
246 text: qsTr("Confirm")
247 }
248 \endqml
249
250 Suppose you then needed to do a one-off customization of the Button (as
251 explained in \l {Customizing a Control}):
252
253 \include customize-button-background.qdocinc file
254
255 In QML, this would normally result in both the default \c background
256 implementation and the one-off, custom \c background items being created.
257 Qt Quick Controls uses a technique that avoids creating both items, and
258 instead only creates the custom \c background, greatly improving the
259 creation performance of controls.
260
261 This technique relies on the absence of an \l {The id Attribute}{id} in the
262 style's implementation of that item. If an id is assigned, the technique
263 cannot work, and both items will be created. For example, it can be
264 tempting to assign an id to the \c background or \c contentItem so that
265 other objects within the file can refer to those items:
266
267 \qml
268 T.Button {
269 // ...
270
271 background: Rectangle {
272 id: backgroundRect
273 // ...
274 }
275
276 contentItem: Text {
277 // Use backgroundRect in some way...
278 }
279
280 // ...
281 }
282 \endqml
283
284 With this code, every time a Button instance with a customized background
285 is created, both backgrounds will be created, resulting in sub-optimal
286 creation performance.
287
288 Prior to Qt 5.15, the old, unused background would be deleted to release
289 the resources associated with it. However, as the control does not own the
290 items, it should not delete them. As of Qt 5.15, old items are no longer
291 deleted, and so the \c backgroundRect item will live longer than it needs
292 to—typically until the application exits. Although the old item will be
293 hidden, visually unparented from the control, and removed from the
294 accessibility tree, it is important to keep the creation time and memory
295 usage of these unused items in mind when assigning an id in this context.
296
297 \section4 Avoid imperative assignments of custom items
298
299 The technique mentioned in the section above only works when an item is
300 \l {Prefer Declarative Bindings Over Imperative Assignments}{declaratively}
301 assigned for the first time, and so imperative assignments will result in
302 orphaned items. Always use declarative bindings to assign custom items
303 when possible.
304
305 \section4 Don't import QtQuick.Controls in QML implementations
306
307 When writing the QML for your style's implementation of a control,
308 it's important not to import \c {QtQuick.Controls}. Doing so will
309 prevent the QML from being compiled by the QML compiler.
310
311 \section4 Implement types used by other types
312
313 Suppose you were using ScrollViews in your application, and decided that
314 you want to customize their scroll bars. It is tempting to just implement a
315 custom ScrollBar.qml and have ScrollView pick up the customized ScrollBar
316 automatically. However, this will not work. You must implement both
317 ScrollBar.qml \e and ScrollView.qml.
318
319 \section3 Attached properties
320
321 It is common for a style to have certain properties or attributes that
322 apply to all controls. \l {Attached Properties and Attached Signal
323 Handlers}{Attached properties} are a great way of extending an item in QML
324 without having to modify any existing C++ belonging to that item. For
325 example, both the \l {Material Style}{Material} and \l {Universal
326 Style}{Universal} styles have an attached theme property that controls
327 whether an item and its children will be rendered in a light or dark theme.
328
329 As an example, let's add an attached property that controls elevation. Our
330 style will illustrate the elevation with a drop shadow; the higher the
331 elevation, the larger the shadow.
332
333 The first step is to \l {Qt Creator: Project Types}{create a new Qt Quick
334 Controls application} in Qt Creator. After that, we
335 \l {Qt Creator: Creating C++ Classes}{add a C++ type} that stores the elevation. Since
336 the type will be used for every control supported by our style, and because
337 we may wish to add other attached properties later on, we'll call it
338 MyStyle. Here is \c MyStyle.h:
339
340 \code
341 #ifndef MYSTYLE_H
342 #define MYSTYLE_H
343
344 #include <QObject>
345 #include <QtQml>
346
347 class MyStyle : public QObject
348 {
349 Q_OBJECT
350 Q_PROPERTY(int elevation READ elevation WRITE setElevation NOTIFY elevationChanged)
351
352 public:
353 explicit MyStyle(QObject *parent = nullptr);
354
355 static MyStyle *qmlAttachedProperties(QObject *object);
356
357 int elevation() const;
358 void setElevation(int elevation);
359
360 signals:
361 void elevationChanged();
362
363 private:
364 int m_elevation;
365 };
366
367 QML_DECLARE_TYPEINFO(MyStyle, QML_HAS_ATTACHED_PROPERTIES)
368
369 #endif // MYSTYLE_H
370 \endcode
371
372 \c MyStyle.cpp:
373
374 \code
375 #include "mystyle.h"
376
377 MyStyle::MyStyle(QObject *parent) :
378 QObject(parent),
379 m_elevation(0)
380 {
381 }
382
383 MyStyle *MyStyle::qmlAttachedProperties(QObject *object)
384 {
385 return new MyStyle(object);
386 }
387
388 int MyStyle::elevation() const
389 {
390 return m_elevation;
391 }
392
393 void MyStyle::setElevation(int elevation)
394 {
395 if (elevation == m_elevation)
396 return;
397
398 m_elevation = elevation;
399 emit elevationChanged();
400 }
401 \endcode
402
403 The \c MyStyle type is special in the sense that it shouldn't be
404 instantiated, but rather used for its attached properties. For that reason,
405 we register it in the following manner in \c main.cpp:
406
407 \code
408 #include <QGuiApplication>
409 #include <QQmlApplicationEngine>
410
411 #include "mystyle.h"
412
413 int main(int argc, char *argv[])
414 {
415 QGuiApplication app(argc, argv);
416
417 qmlRegisterUncreatableType<MyStyle>("MyStyle", 1, 0, "MyStyle", "MyStyle is an attached property");
418
419 QQmlApplicationEngine engine;
420 // Make the directory containing our style known to the QML engine.
421 engine.addImportPath(":/");
422 engine.load(QUrl(QLatin1String("qrc:/main.qml")));
423
424 return app.exec();
425 }
426 \endcode
427
428 We then copy \c Button.qml from the Basic style in
429 \c {$QTDIR/qml/QtQuick/Controls/Basic/} into a new \c myproject folder in our
430 project directory. Add the newly copied \c Button.qml to \c qml.qrc, which is
431 the resource file that contains our QML files.
432
433 Next, we add a drop shadow to the \l {Control::}{background} delegate of
434 the Button:
435
436 \code
437 // ...
438 import QtGraphicalEffects
439 import MyStyle
440 // ...
441
442 background: Rectangle {
443 // ...
444
445 layer.enabled: control.enabled && control.MyStyle.elevation > 0
446 layer.effect: DropShadow {
447 verticalOffset: 1
448 color: control.visualFocus ? "#330066ff" : "#aaaaaa"
449 samples: control.MyStyle.elevation
450 spread: 0.5
451 }
452 }
453 \endcode
454
455 Note that we:
456
457 \list
458 \li Don't bother using the drop shadow when the elevation is \c 0
459 \li Change the shadow's color depending on whether or not the button has
460 focus
461 \li Make the size of the shadow depend on the elevation
462 \endlist
463
464 To try out the attached property, we create a \l Row with two Buttons in
465 \c main.qml:
466
467 \qml
468 import QtQuick
469 import QtQuick.Controls
470
471 import MyStyle 1.0
472
473 ApplicationWindow {
474 id: window
475 width: 400
476 height: 400
477 visible: true
478
479 Row {
480 spacing: 20
481 anchors.centerIn: parent
482
483 Button {
484 text: "Button 1"
485 }
486 Button {
487 text: "Button 2"
488 MyStyle.elevation: 10
489 }
490 }
491 }
492 \endqml
493
494 One button has no elevation, and the other has an elevation of \c 10.
495
496 With that in place, we can run our example. To tell the application to
497 use our new style, we pass \c {-style MyStyle} as an application
498 argument, but there are \l {Using Styles in Qt Quick Controls}{many
499 ways} to specify the style to use.
500
501 The end result:
502
503 \image qtquickcontrols-customize-buttons.png
504
505 Note that the \c {import MyStyle 1.0} statement is only necessary
506 because we are using the attached property belonging to \c MyStyle.
507 Both buttons will use our custom style, even if we were to remove the
508 import.
509
510 \section1 Customization Reference
511
512 The following snippets present examples where the Basic style's controls
513 have been customized using the same approach as the
514 \l {Customizing a Control} section. The code can be used as a starting
515 point to implement a custom look and feel.
516
517 \note The \l {macOS Style}{macOS} and \l {Windows Style}{Windows} styles
518 are not suitable for customizing.
519 \include customizing-native-styles.qdocinc
520
521 \section2 Customizing ApplicationWindow
522
523 ApplicationWindow consists of one visual item:
524 \l {ApplicationWindow::background}{background}.
525
526 \code
527 import QtQuick
528 import QtQuick.Controls
529
530 ApplicationWindow {
531 visible: true
532
533 background: Rectangle {
534 gradient: Gradient {
535 GradientStop { position: 0; color: "#ffffff" }
536 GradientStop { position: 1; color: "#c1bbf9" }
537 }
538 }
539 }
540 \endcode
541
542
543 \section2 Customizing BusyIndicator
544
545 BusyIndicator consists of two visual items: \l {Control::background}{background}
546 and \l {Control::contentItem}{contentItem}.
547
548 \image qtquickcontrols-busyindicator-custom.png
549
550 \snippet qtquickcontrols-busyindicator-custom.qml file
551
552
553 \section2 Customizing Button
554
555 Button consists of two visual items: \l {Control::background}{background}
556 and \l {Control::contentItem}{content item}.
557
558 \image qtquickcontrols-button-custom.png
559
560 \snippet qtquickcontrols-button-custom.qml file
561
562
563 \section2 Customizing CheckBox
564
565 CheckBox consists of three visual items: \l {Control::background}{background},
566 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
567
568 \image qtquickcontrols-checkbox-custom.png
569
570 \snippet qtquickcontrols-checkbox-custom.qml file
571
572 \section2 Customizing CheckDelegate
573
574 CheckDelegate consists of three visual items: \l {Control::background}{background},
575 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
576
577 \image qtquickcontrols-checkdelegate-custom.png
578
579 \snippet qtquickcontrols-checkdelegate-custom.qml file
580
581
582 \section2 Customizing ComboBox
583
584 ComboBox consists of \l {Control::background}{background},
585 \l {Control::contentItem}{content item}, \l {ComboBox::popup}{popup},
586 \l {ComboBox::indicator}{indicator}, and \l {ComboBox::delegate}{delegate}.
587
588 \image qtquickcontrols-combobox-custom.png
589
590 \snippet qtquickcontrols-combobox-custom.qml file
591
592 As explained in \l {ComboBox Model Roles}, ComboBox supports multiple
593 types of models.
594
595 Since \l {qml-data-models}{all the models provide an anonymous property}
596 with \c modelData, the following expression retrieves the right text in
597 all cases:
598
599 \code
600 text: model[control.textRole]
601 \endcode
602
603 When you provide a specific \c textRole and a model with structured
604 data that provides the selected role, this is expression is a regular
605 property lookup. When you provide a model with singular data, such as
606 a list of strings, and an empty \c textRole, this expression retrieves
607 the \c modelData.
608
609 \section2 Customizing DelayButton
610
611 DelayButton consists of two visual items: \l {Control::background}{background}
612 and \l {Control::contentItem}{content item}.
613
614 \image qtquickcontrols-delaybutton-custom.png
615
616 \snippet qtquickcontrols-delaybutton-custom.qml file
617
618
619 \section2 Customizing Dial
620
621 Dial consists of two visual items: \l {Control::background}{background}
622 and \l {Dial::handle}{handle}.
623
624 \image qtquickcontrols-dial-custom.png
625
626 \snippet qtquickcontrols-dial-custom.qml file
627
628
629 \section2 Customizing Drawer
630
631 Drawer can have a visual \l {Control::background}{background}
632 item.
633
634 \code
635 background: Rectangle {
636 Rectangle {
637 x: parent.width - 1
638 width: 1
639 height: parent.height
640 color: "#21be2b"
641 }
642 }
643 \endcode
644
645
646 \section2 Customizing Frame
647
648 Frame consists of one visual item: \l {Control::background}{background}.
649
650 \image qtquickcontrols-frame-custom.png
651
652 \snippet qtquickcontrols-frame-custom.qml file
653
654
655 \section2 Customizing GroupBox
656
657 GroupBox consists of two visual items: \l {Control::background}{background}
658 and \l {GroupBox::label}{label}.
659
660 \image qtquickcontrols-groupbox-custom.png
661
662 \snippet qtquickcontrols-groupbox-custom.qml file
663
664
665 \section2 Customizing ItemDelegate
666
667 ItemDelegate consists of two visual items: \l {Control::background}{background}
668 and \l {Control::contentItem}{content item}.
669
670 \image qtquickcontrols-itemdelegate-custom.png
671
672 \snippet qtquickcontrols-itemdelegate-custom.qml file
673
674
675 \section2 Customizing Label
676
677 Label can have a visual \l {Label::background}{background} item.
678
679 \image qtquickcontrols-label-custom.png
680
681 \snippet qtquickcontrols-label-custom.qml file
682
683
684 \section2 Customizing Menu
685
686 \list
687 \li \l Menu consists of a visual \l {Popup::background}{background} item.
688 \li \l MenuItem consists of four visual items: \l {Control::background}{background},
689 \l {Control::contentItem}{content item}, \l {AbstractButton::}{indicator}, and
690 \l {MenuItem::}{arrow}.
691 \li \l MenuSeparator consists of a visual \l {Control::background}{background} and
692 \l {Control::contentItem}{content item}.
693 \endlist
694
695 \image qtquickcontrols-menu-custom.png
696
697 \quotefromfile qtquickcontrols-menu-custom.qml
698 \skipto import QtQuick
699 \printuntil import QtQuick.Controls
700 \skipto Menu
701 \printto eof
702
703
704 \section2 Customizing MenuBar
705
706 MenuBar can have a visual \l {Control::background}{background} item,
707 and MenuBarItem consists of two visual items: \l {Control::background}
708 {background} and \l {Control::contentItem}{content item}.
709
710 \image qtquickcontrols-menubar-custom.png
711
712 \quotefromfile qtquickcontrols-menubar-custom.qml
713 \skipto import QtQuick
714 \printuntil import QtQuick.Controls
715 \skipto MenuBar
716 \printto eof
717
718
719 \section2 Customizing PageIndicator
720
721 PageIndicator consists of a \l {Control::background}{background}, \l {Control::contentItem}{content item}, and \l {PageIndicator::delegate}{delegate}.
722
723 \image qtquickcontrols-pageindicator-custom.png
724
725 \snippet qtquickcontrols-pageindicator-custom.qml file
726
727
728 \section2 Customizing Pane
729
730 Pane consists of a \l {Control::background}{background}.
731
732 \image qtquickcontrols-pane-custom.png
733
734 \snippet qtquickcontrols-pane-custom.qml file
735
736
737 \section2 Customizing Popup
738
739 Popup consists of a \l {Popup::background}{background} and
740 \l {Popup::contentItem}{content item}.
741
742 \image qtquickcontrols-popup-custom.png
743
744 \quotefromfile qtquickcontrols-popup-custom.qml
745 \skipto import QtQuick
746 \printuntil import QtQuick.Controls
747 \codeline
748 \skipto Popup
749 \printuntil {
750 \printuntil }
751 \printuntil }
752 \printuntil }
753
754
755 \section2 Customizing ProgressBar
756
757 ProgressBar consists of two visual items: \l {Control::background}{background}
758 and \l {Control::contentItem}{content item}.
759
760 \image qtquickcontrols-progressbar-custom.png
761
762 \snippet qtquickcontrols-progressbar-custom.qml file
763
764
765 \section2 Customizing RadioButton
766
767 RadioButton consists of three visual items: \l {Control::background}{background},
768 \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
769
770 \image qtquickcontrols-radiobutton-custom.png
771
772 \snippet qtquickcontrols-radiobutton-custom.qml file
773
774
775 \section2 Customizing RadioDelegate
776
777 RadioDelegate consists of three visual items: \l {Control::background}{background},
778 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
779
780 \image qtquickcontrols-radiodelegate-custom.png
781
782 \snippet qtquickcontrols-radiodelegate-custom.qml file
783
784
785 \section2 Customizing RangeSlider
786
787 RangeSlider consists of three visual items:
788 \l {Control::background}{background},
789 \l {RangeSlider::first}{first.handle} and
790 \l {RangeSlider::second.handle}{second.handle}.
791
792 \image qtquickcontrols-rangeslider-custom.png
793
794 \snippet qtquickcontrols-rangeslider-custom.qml file
795
796
797 \section2 Customizing RoundButton
798
799 RoundButton can be customized in the same manner as
800 \l {Customizing Button}{Button}.
801
802
803 \section2 Customizing ScrollBar
804
805 ScrollBar consists of two visual items: \l {Control::background}{background}
806 and \l {Control::contentItem}{content item}.
807
808 \image qtquickcontrols-scrollbar-custom.png
809
810 \snippet qtquickcontrols-scrollbar-custom.qml file
811
812
813 \section2 Customizing ScrollIndicator
814
815 ScrollIndicator consists of two visual items: \l {Control::background}{background}
816 and \l {Control::contentItem}{content item}.
817
818 \image qtquickcontrols-scrollindicator-custom.png
819
820 \snippet qtquickcontrols-scrollindicator-custom.qml file
821
822
823 \section2 Customizing ScrollView
824
825 ScrollView consists of a \l {Control::background}{background} item,
826 and horizontal and vertical scroll bars.
827
828 \image qtquickcontrols-scrollview-custom.png
829
830 \snippet qtquickcontrols-scrollview-custom.qml file
831
832
833 \section2 Customizing Slider
834
835 Slider consists of two visual items: \l {Control::background}{background},
836 and \l {Slider::handle}{handle}.
837
838 \image qtquickcontrols-slider-custom.png
839
840 \snippet qtquickcontrols-slider-custom.qml file
841
842
843 \section2 Customizing SpinBox
844
845 SpinBox consists of four visual items: \l {Control::background}{background},
846 \l {Control::contentItem}{contentItem}, \l {SpinBox::up.indicator}{up indicator},
847 and \l {SpinBox::down.indicator}{down indicator}.
848
849 \image qtquickcontrols-spinbox-custom.png
850
851 \snippet qtquickcontrols-spinbox-custom.qml file
852
853
854 \section2 Customizing SplitView
855
856 SplitView consists of a visual \l {SplitView::handle}{handle} delegate.
857
858 \image qtquickcontrols-splitview-custom.png
859
860 \snippet qtquickcontrols-splitview-custom.qml 1
861
862
863 \section2 Customizing StackView
864
865 StackView can have a visual \l {Control::background}{background}
866 item, and it allows customizing the transitions that are used for
867 push, pop, and replace operations.
868
869 \snippet qtquickcontrols-stackview-custom.qml file
870
871
872 \section2 Customizing SwipeDelegate
873
874 SwipeDelegate consists of six visual items: \l {Control::background}{background},
875 \l {Control::contentItem}{content item}, \l {AbstractButton::indicator}{indicator},
876 \c swipe.left, \c swipe.right, and \c swipe.behind.
877
878 \image qtquickcontrols-swipedelegate-custom.png
879
880 \snippet qtquickcontrols-swipedelegate-custom.qml file
881
882
883 \section2 Customizing SwipeView
884
885 SwipeView can have a visual \l {Control::background}{background}
886 item. The navigation is implemented by the \l {Control::contentItem}
887 {content item}.
888
889 \snippet qtquickcontrols-swipeview-custom.qml file
890
891
892 \section2 Customizing Switch
893
894 Switch consists of three visual items: \l {Control::background}{background},
895 \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
896
897 \image qtquickcontrols-switch-custom.png
898
899 \snippet qtquickcontrols-switch-custom.qml file
900
901 \section2 Customizing SwitchDelegate
902
903 SwitchDelegate consists of three visual items: \l {Control::background}{background},
904 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
905
906 \image qtquickcontrols-switchdelegate-custom.png
907
908 \snippet qtquickcontrols-switchdelegate-custom.qml file
909
910
911 \section2 Customizing TabBar
912
913 TabBar consists of two visual items: \l {Control::background}{background},
914 and \l {Control::contentItem}{contentItem}.
915
916 \image qtquickcontrols-tabbar-custom.png
917
918 \snippet qtquickcontrols-tabbar-custom.qml file
919
920
921 \section2 Customizing TabButton
922
923 TabButton can be customized in the same manner as
924 \l {Customizing Button}{Button}.
925
926
927 \section2 Customizing TextArea
928
929 TextArea consists of a \l {TextArea::background}{background} item.
930
931 \image qtquickcontrols-textarea-custom.png
932
933 \snippet qtquickcontrols-textarea-custom.qml file
934
935
936 \section2 Customizing TextField
937
938 TextField consists of a \l {TextField::background}{background} item.
939
940 \image qtquickcontrols-textfield-custom.png
941
942 \snippet qtquickcontrols-textfield-custom.qml file
943
944
945 \section2 Customizing ToolBar
946
947 ToolBar consists of one visual item: \l {Control::background}{background}.
948
949 \image qtquickcontrols-toolbar-custom.png
950
951 \snippet qtquickcontrols-toolbar-custom.qml file
952
953
954 \section2 Customizing ToolButton
955
956 ToolButton consists of two visual items: \l {Control::background}{background}
957 and \l {Control::contentItem}{content item}.
958
959 \image qtquickcontrols-toolbutton-custom.png
960
961 \snippet qtquickcontrols-toolbutton-custom.qml file
962
963
964 \section2 Customizing ToolSeparator
965
966 ToolSeparator consists of two visual items: \l {Control::background}{background}
967 and \l {Control::contentItem}{content item}.
968
969 \image qtquickcontrols-toolseparator-custom.png
970
971 \snippet qtquickcontrols-toolseparator-custom.qml file
972
973
974 \section2 Customizing ToolTip
975
976 ToolTip consists of two visual items: \l {Popup::background}{background}
977 and \l {Popup::contentItem}{content item}.
978
979 \quotefromfile qtquickcontrols-tooltip-custom.qml
980 \skipto import QtQuick
981 \printuntil import QtQuick.Controls
982 \skipto ToolTip
983 \printuntil }
984 \printuntil }
985 \printuntil }
986
987 \include qquicktooltip.qdocinc customize-note
988
989 \section2 Customizing Tumbler
990
991 Tumbler consists of three visual items:
992 \l {Control::background}{background},
993 \l {Control::contentItem}{contentItem}, and
994 \l {Tumbler::delegate}{delegate}.
995
996 \image qtquickcontrols-tumbler-custom.png
997
998 \snippet qtquickcontrols-tumbler-custom.qml file
999
1000 If you want to define your own contentItem, use either a \l ListView or
1001 \l PathView as the root item. For a wrapping Tumbler, use PathView:
1002
1003 \snippet qtquickcontrols-tumbler-pathView.qml contentItem
1004
1005 For a non-wrapping Tumbler, use ListView:
1006
1007 \snippet qtquickcontrols-tumbler-listView.qml contentItem
1008*/