Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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.
187
188 \list
189 \li If the style that uses the type is the only style used by an
190 application, register the type with the QML engine by adding the QML_ELEMENT
191 macro and making the file part of your QML module:
192 \br
193 \br
194
195 \if defined(onlinedocs)
196 \tab {expose-cpp-to-qml}{tab-cmake}{CMake}{checked}
197 \tab {expose-cpp-to-qml}{tab-qmake}{qmake}{}
198 \tabcontent {tab-cmake}
199 \else
200 \section3 Using CMake
201 \endif
202 \badcode
203 qt_add_qml_module(ACoolItem
204 URI MyItems
205 VERSION 1.0
206 SOURCES
207 acoolcppitem.cpp acoolcppitem.h
208 )
209 \endcode
210 \if defined(onlinedocs)
211 \endtabcontent
212 \tabcontent {tab-qmake}
213 \else
214 \section3 Using QMake
215 \endif
216 \code
217 CONFIG += qmltypes
218 QML_IMPORT_NAME = MyItems
219 QML_IMPORT_MAJOR_VERSION = 1
220 \endcode
221
222 If the header the class is declared in is not accessible from your
223 project's include path, you may have to amend the include path so
224 that the generated registration code can be compiled.
225
226 \code
227 INCLUDEPATH += MyItems
228 \endcode
229 \if defined(onlinedocs)
230 \endtabcontent
231 \endif
232
233 See \l {Defining QML Types from C++} and \l {Building a QML application}
234 for more information.
235 \li If the style that uses the type is one of many styles used by an
236 application, consider putting each style into a separate module. The
237 modules will then be loaded on demand.
238 \endlist
239
240 \section3 Considerations for custom styles
241
242 When implementing your own style and customizing controls, there are some
243 points to keep in mind to ensure that your application is as performant as
244 possible.
245
246 \section4 Avoid assigning an id to styles' implementations of item delegates
247
248 As explained in \l {Definition of a Style}, when you implement your
249 own style for a control, you start off with the relevant template for
250 that control. For example, a style's \c Button.qml will be structured
251 similarly to this:
252
253 \qml
254 T.Button {
255 // ...
256
257 background: Rectangle {
258 // ...
259 }
260
261 contentItem: Text {
262 // ...
263 }
264
265 // ...
266 }
267 \endqml
268
269 When you use a Button in your application, the \c background and
270 \c contentItem items will be created and parented to the root \c Button
271 item:
272
273 \qml
274 // Creates the Button root item, the Rectangle background,
275 // and the Text contentItem.
276 Button {
277 text: qsTr("Confirm")
278 }
279 \endqml
280
281 Suppose you then needed to do a one-off customization of the Button (as
282 explained in \l {Customizing a Control}):
283
284 \include customize-button-background.qdocinc file
285
286 In QML, this would normally result in both the default \c background
287 implementation and the one-off, custom \c background items being created.
288 Qt Quick Controls uses a technique that avoids creating both items, and
289 instead only creates the custom \c background, greatly improving the
290 creation performance of controls.
291
292 This technique relies on the absence of an \l {The id Attribute}{id} in the
293 style's implementation of that item. If an id is assigned, the technique
294 cannot work, and both items will be created. For example, it can be
295 tempting to assign an id to the \c background or \c contentItem so that
296 other objects within the file can refer to those items:
297
298 \qml
299 T.Button {
300 // ...
301
302 background: Rectangle {
303 id: backgroundRect
304 // ...
305 }
306
307 contentItem: Text {
308 // Use backgroundRect in some way...
309 }
310
311 // ...
312 }
313 \endqml
314
315 With this code, every time a Button instance with a customized background
316 is created, both backgrounds will be created, resulting in sub-optimal
317 creation performance.
318
319 Prior to Qt 5.15, the old, unused background would be deleted to release
320 the resources associated with it. However, as the control does not own the
321 items, it should not delete them. As of Qt 5.15, old items are no longer
322 deleted, and so the \c backgroundRect item will live longer than it needs
323 to—typically until the application exits. Although the old item will be
324 hidden, visually unparented from the control, and removed from the
325 accessibility tree, it is important to keep the creation time and memory
326 usage of these unused items in mind when assigning an id in this context.
327
328 \section4 Avoid imperative assignments of custom items
329
330 The technique mentioned in the section above only works when an item is
331 \l {Prefer Declarative Bindings Over Imperative Assignments}{declaratively}
332 assigned for the first time, and so imperative assignments will result in
333 orphaned items. Always use declarative bindings to assign custom items
334 when possible.
335
336 \section4 Don't import QtQuick.Controls in QML implementations
337
338 When writing the QML for your style's implementation of a control,
339 it's important not to import \c {QtQuick.Controls}. Doing so will
340 prevent the QML from being compiled by the QML compiler.
341
342 \section4 Implement types used by other types
343
344 Suppose you were using ScrollViews in your application, and decided that
345 you want to customize their scroll bars. It is tempting to just implement a
346 custom ScrollBar.qml and have ScrollView pick up the customized ScrollBar
347 automatically. However, this will not work. You must implement both
348 ScrollBar.qml \e and ScrollView.qml.
349
350 \section3 Attached properties
351
352 It is common for a style to have certain properties or attributes that
353 apply to all controls. \l {Attached Properties and Attached Signal
354 Handlers}{Attached properties} are a great way of extending an item in QML
355 without having to modify any existing C++ belonging to that item. For
356 example, both the \l {Material Style}{Material} and \l {Universal
357 Style}{Universal} styles have an attached theme property that controls
358 whether an item and its children will be rendered in a light or dark theme.
359
360 As an example, let's add an attached property that controls elevation. Our
361 style will illustrate the elevation with a drop shadow; the higher the
362 elevation, the larger the shadow.
363
364 The first step is to \l {Qt Creator: Project Types}{create a new Qt Quick
365 Controls application} in Qt Creator. After that, we
366 \l {Qt Creator: Creating C++ Classes}{add a C++ type} that stores the elevation. Since
367 the type will be used for every control supported by our style, and because
368 we may wish to add other attached properties later on, we'll call it
369 MyStyle. Here is \c MyStyle.h:
370
371 \code
372 #ifndef MYSTYLE_H
373 #define MYSTYLE_H
374
375 #include <QObject>
376 #include <QtQml>
377
378 class MyStyle : public QObject
379 {
380 Q_OBJECT
381 Q_PROPERTY(int elevation READ elevation WRITE setElevation NOTIFY elevationChanged)
382
383 public:
384 explicit MyStyle(QObject *parent = nullptr);
385
386 static MyStyle *qmlAttachedProperties(QObject *object);
387
388 int elevation() const;
389 void setElevation(int elevation);
390
391 signals:
392 void elevationChanged();
393
394 private:
395 int m_elevation;
396 };
397
398 QML_DECLARE_TYPEINFO(MyStyle, QML_HAS_ATTACHED_PROPERTIES)
399
400 #endif // MYSTYLE_H
401 \endcode
402
403 \c MyStyle.cpp:
404
405 \code
406 #include "mystyle.h"
407
408 MyStyle::MyStyle(QObject *parent) :
409 QObject(parent),
410 m_elevation(0)
411 {
412 }
413
414 MyStyle *MyStyle::qmlAttachedProperties(QObject *object)
415 {
416 return new MyStyle(object);
417 }
418
419 int MyStyle::elevation() const
420 {
421 return m_elevation;
422 }
423
424 void MyStyle::setElevation(int elevation)
425 {
426 if (elevation == m_elevation)
427 return;
428
429 m_elevation = elevation;
430 emit elevationChanged();
431 }
432 \endcode
433
434 The \c MyStyle type is special in the sense that it shouldn't be
435 instantiated, but rather used for its attached properties. For that reason,
436 we register it in the following manner in \c main.cpp:
437
438 \code
439 #include <QGuiApplication>
440 #include <QQmlApplicationEngine>
441
442 #include "mystyle.h"
443
444 int main(int argc, char *argv[])
445 {
446 QGuiApplication app(argc, argv);
447
448 qmlRegisterUncreatableType<MyStyle>("MyStyle", 1, 0, "MyStyle", "MyStyle is an attached property");
449
450 QQmlApplicationEngine engine;
451 // Make the directory containing our style known to the QML engine.
452 engine.addImportPath(":/");
453 engine.load(QUrl(QLatin1String("qrc:/main.qml")));
454
455 return app.exec();
456 }
457 \endcode
458
459 We then copy \c Button.qml from the Basic style in
460 \c {$QTDIR/qml/QtQuick/Controls/Basic/} into a new \c myproject folder in our
461 project directory. Add the newly copied \c Button.qml to \c qml.qrc, which is
462 the resource file that contains our QML files.
463
464 Next, we add a drop shadow to the \l {Control::}{background} delegate of
465 the Button:
466
467 \qml
468 // ...
469 import QtQuick.Effects
470 import MyStyle
471 // ...
472
473 background: Rectangle {
474 // ...
475
476 layer.enabled: control.enabled && control.MyStyle.elevation > 0
477 layer.effect: MultiEffect {
478 shadowEnabled: true
479 shadowHorizontalOffset: 3
480 shadowVerticalOffset: 3
481 shadowColor: control.visualFocus ? "#330066ff" : "#aaaaaa"
482 shadowBlur: control.pressed ? 0.8 : 0.4
483 }
484 }
485 \endqml
486
487 Note that we:
488
489 \list
490 \li Don't bother using the drop shadow when the elevation is \c 0
491 \li Change the shadow's color depending on whether or not the button has
492 focus
493 \li Make the size of the shadow depend on the elevation
494 \endlist
495
496 To try out the attached property, we create a \l Row with two Buttons in
497 \c main.qml:
498
499 \qml
500 import QtQuick
501 import QtQuick.Controls
502
503 import MyStyle 1.0
504
505 ApplicationWindow {
506 id: window
507 width: 400
508 height: 400
509 visible: true
510
511 Row {
512 spacing: 20
513 anchors.centerIn: parent
514
515 Button {
516 text: "Button 1"
517 }
518 Button {
519 text: "Button 2"
520 MyStyle.elevation: 10
521 }
522 }
523 }
524 \endqml
525
526 One button has no elevation, and the other has an elevation of \c 10.
527
528 With that in place, we can run our example. To tell the application to
529 use our new style, we pass \c {-style MyStyle} as an application
530 argument, but there are \l {Using Styles in Qt Quick Controls}{many
531 ways} to specify the style to use.
532
533 The end result:
534
535 \image qtquickcontrols-customize-buttons.png
536
537 Note that the \c {import MyStyle 1.0} statement is only necessary
538 because we are using the attached property belonging to \c MyStyle.
539 Both buttons will use our custom style, even if we were to remove the
540 import.
541
542 \section1 Customization Reference
543
544 The following snippets present examples where the Basic style's controls
545 have been customized using the same approach as the
546 \l {Customizing a Control} section. The code can be used as a starting
547 point to implement a custom look and feel.
548
549 \note The \l {macOS Style}{macOS} and \l {Windows Style}{Windows} styles
550 are not suitable for customizing.
551 \include customizing-native-styles.qdocinc
552
553 \section2 Customizing ApplicationWindow
554
555 ApplicationWindow consists of one visual item:
556 \l {ApplicationWindow::background}{background}.
557
558 \code
559 import QtQuick
560 import QtQuick.Controls
561
562 ApplicationWindow {
563 visible: true
564
565 background: Rectangle {
566 gradient: Gradient {
567 GradientStop { position: 0; color: "#ffffff" }
568 GradientStop { position: 1; color: "#c1bbf9" }
569 }
570 }
571 }
572 \endcode
573
574
575 \section2 Customizing BusyIndicator
576
577 BusyIndicator consists of two visual items: \l {Control::background}{background}
578 and \l {Control::contentItem}{contentItem}.
579
580 \image qtquickcontrols-busyindicator-custom.png
581
582 \snippet qtquickcontrols-busyindicator-custom.qml file
583
584
585 \section2 Customizing Button
586
587 Button consists of two visual items: \l {Control::background}{background}
588 and \l {Control::contentItem}{content item}.
589
590 \image qtquickcontrols-button-custom.png
591
592 \snippet qtquickcontrols-button-custom.qml file
593
594
595 \section2 Customizing CheckBox
596
597 CheckBox consists of three visual items: \l {Control::background}{background},
598 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
599
600 \image qtquickcontrols-checkbox-custom.png
601
602 \snippet qtquickcontrols-checkbox-custom.qml file
603
604 \section2 Customizing CheckDelegate
605
606 CheckDelegate consists of three visual items: \l {Control::background}{background},
607 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
608
609 \image qtquickcontrols-checkdelegate-custom.png
610
611 \snippet qtquickcontrols-checkdelegate-custom.qml file
612
613
614 \section2 Customizing ComboBox
615
616 ComboBox consists of \l {Control::background}{background},
617 \l {Control::contentItem}{content item}, \l {ComboBox::popup}{popup},
618 \l {ComboBox::indicator}{indicator}, and \l {ComboBox::delegate}{delegate}.
619
620 \image qtquickcontrols-combobox-custom.png
621
622 \snippet qtquickcontrols-combobox-custom.qml file
623
624 As explained in \l {ComboBox Model Roles}, ComboBox supports multiple
625 types of models.
626
627 Since \l {qml-data-models}{all the models provide an anonymous property}
628 with \c modelData, the following expression retrieves the right text in
629 all cases:
630
631 \code
632 text: model[control.textRole]
633 \endcode
634
635 When you provide a specific \c textRole and a model with structured
636 data that provides the selected role, this is expression is a regular
637 property lookup. When you provide a model with singular data, such as
638 a list of strings, and an empty \c textRole, this expression retrieves
639 the \c modelData.
640
641 \section2 Customizing DelayButton
642
643 DelayButton consists of two visual items: \l {Control::background}{background}
644 and \l {Control::contentItem}{content item}.
645
646 \image qtquickcontrols-delaybutton-custom.png
647
648 \snippet qtquickcontrols-delaybutton-custom.qml file
649
650
651 \section2 Customizing Dial
652
653 Dial consists of two visual items: \l {Control::background}{background}
654 and \l {Dial::handle}{handle}.
655
656 \image qtquickcontrols-dial-custom.png
657
658 \snippet qtquickcontrols-dial-custom.qml file
659
660
661 \section2 Customizing Drawer
662
663 Drawer can have a visual \l {Control::background}{background}
664 item.
665
666 \code
667 background: Rectangle {
668 Rectangle {
669 x: parent.width - 1
670 width: 1
671 height: parent.height
672 color: "#21be2b"
673 }
674 }
675 \endcode
676
677
678 \section2 Customizing Frame
679
680 Frame consists of one visual item: \l {Control::background}{background}.
681
682 \image qtquickcontrols-frame-custom.png
683
684 \snippet qtquickcontrols-frame-custom.qml file
685
686
687 \section2 Customizing GroupBox
688
689 GroupBox consists of two visual items: \l {Control::background}{background}
690 and \l {GroupBox::label}{label}.
691
692 \image qtquickcontrols-groupbox-custom.png
693
694 \snippet qtquickcontrols-groupbox-custom.qml file
695
696
697 \section2 Customizing ItemDelegate
698
699 ItemDelegate consists of two visual items: \l {Control::background}{background}
700 and \l {Control::contentItem}{content item}.
701
702 \image qtquickcontrols-itemdelegate-custom.png
703
704 \snippet qtquickcontrols-itemdelegate-custom.qml file
705
706
707 \section2 Customizing Label
708
709 Label can have a visual \l {Label::background}{background} item.
710
711 \image qtquickcontrols-label-custom.png
712
713 \snippet qtquickcontrols-label-custom.qml file
714
715
716 \section2 Customizing Menu
717
718 \list
719 \li \l Menu consists of a visual \l {Popup::background}{background} item.
720 \li \l MenuItem consists of four visual items: \l {Control::background}{background},
721 \l {Control::contentItem}{content item}, \l {AbstractButton::}{indicator}, and
722 \l {MenuItem::}{arrow}.
723 \li \l MenuSeparator consists of a visual \l {Control::background}{background} and
724 \l {Control::contentItem}{content item}.
725 \endlist
726
727 \image qtquickcontrols-menu-custom.png
728
729 \quotefromfile qtquickcontrols-menu-custom.qml
730 \skipto import QtQuick
731 \printuntil import QtQuick.Controls
732 \skipto Menu
733 \printto eof
734
735
736 \section2 Customizing MenuBar
737
738 MenuBar can have a visual \l {Control::background}{background} item,
739 and MenuBarItem consists of two visual items: \l {Control::background}
740 {background} and \l {Control::contentItem}{content item}.
741
742 \image qtquickcontrols-menubar-custom.png
743
744 \quotefromfile qtquickcontrols-menubar-custom.qml
745 \skipto import QtQuick
746 \printuntil import QtQuick.Controls
747 \skipto MenuBar
748 \printto eof
749
750
751 \section2 Customizing PageIndicator
752
753 PageIndicator consists of a \l {Control::background}{background}, \l {Control::contentItem}{content item}, and \l {PageIndicator::delegate}{delegate}.
754
755 \image qtquickcontrols-pageindicator-custom.png
756
757 \snippet qtquickcontrols-pageindicator-custom.qml file
758
759
760 \section2 Customizing Pane
761
762 Pane consists of a \l {Control::background}{background}.
763
764 \image qtquickcontrols-pane-custom.png
765
766 \snippet qtquickcontrols-pane-custom.qml file
767
768
769 \section2 Customizing Popup
770
771 Popup consists of a \l {Popup::background}{background} and
772 \l {Popup::contentItem}{content item}.
773
774 \image qtquickcontrols-popup-custom.png
775
776 \quotefromfile qtquickcontrols-popup-custom.qml
777 \skipto import QtQuick
778 \printuntil import QtQuick.Controls
779 \codeline
780 \skipto Popup
781 \printuntil {
782 \printuntil }
783 \printuntil }
784 \printuntil }
785
786
787 \section2 Customizing ProgressBar
788
789 ProgressBar consists of two visual items: \l {Control::background}{background}
790 and \l {Control::contentItem}{content item}.
791
792 \image qtquickcontrols-progressbar-custom.png
793
794 \snippet qtquickcontrols-progressbar-custom.qml file
795
796 Above, the content item is also animated to represent an
797 \l {ProgressBar::}{indeterminate} progress bar state.
798
799
800 \section2 Customizing RadioButton
801
802 RadioButton consists of three visual items: \l {Control::background}{background},
803 \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
804
805 \image qtquickcontrols-radiobutton-custom.png
806
807 \snippet qtquickcontrols-radiobutton-custom.qml file
808
809
810 \section2 Customizing RadioDelegate
811
812 RadioDelegate consists of three visual items: \l {Control::background}{background},
813 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
814
815 \image qtquickcontrols-radiodelegate-custom.png
816
817 \snippet qtquickcontrols-radiodelegate-custom.qml file
818
819
820 \section2 Customizing RangeSlider
821
822 RangeSlider consists of three visual items:
823 \l {Control::background}{background},
824 \l {RangeSlider::first}{first.handle} and
825 \l {RangeSlider::second.handle}{second.handle}.
826
827 \image qtquickcontrols-rangeslider-custom.png
828
829 \snippet qtquickcontrols-rangeslider-custom.qml file
830
831
832 \section2 Customizing RoundButton
833
834 RoundButton can be customized in the same manner as
835 \l {Customizing Button}{Button}.
836
837
838 \section2 Customizing ScrollBar
839
840 ScrollBar consists of two visual items: \l {Control::background}{background}
841 and \l {Control::contentItem}{content item}.
842
843 \image qtquickcontrols-scrollbar-custom.png
844
845 \snippet qtquickcontrols-scrollbar-custom.qml file
846
847
848 \section2 Customizing ScrollIndicator
849
850 ScrollIndicator consists of two visual items: \l {Control::background}{background}
851 and \l {Control::contentItem}{content item}.
852
853 \image qtquickcontrols-scrollindicator-custom.png
854
855 \snippet qtquickcontrols-scrollindicator-custom.qml file
856
857
858 \section2 Customizing ScrollView
859
860 ScrollView consists of a \l {Control::background}{background} item,
861 and horizontal and vertical scroll bars.
862
863 \image qtquickcontrols-scrollview-custom.png
864
865 \snippet qtquickcontrols-scrollview-custom.qml file
866
867
868 \section2 Customizing Slider
869
870 Slider consists of two visual items: \l {Control::background}{background},
871 and \l {Slider::handle}{handle}.
872
873 \image qtquickcontrols-slider-custom.png
874
875 \snippet qtquickcontrols-slider-custom.qml file
876
877
878 \section2 Customizing SpinBox
879
880 SpinBox consists of four visual items: \l {Control::background}{background},
881 \l {Control::contentItem}{contentItem}, \l {SpinBox::up.indicator}{up indicator},
882 and \l {SpinBox::down.indicator}{down indicator}.
883
884 \image qtquickcontrols-spinbox-custom.png
885
886 \snippet qtquickcontrols-spinbox-custom.qml file
887
888
889 \section2 Customizing SplitView
890
891 SplitView consists of a visual \l {SplitView::handle}{handle} delegate.
892
893 \image qtquickcontrols-splitview-custom.png
894
895 \snippet qtquickcontrols-splitview-custom.qml 1
896
897
898 \section2 Customizing StackView
899
900 StackView can have a visual \l {Control::background}{background}
901 item, and it allows customizing the transitions that are used for
902 push, pop, and replace operations.
903
904 \snippet qtquickcontrols-stackview-custom.qml file
905
906
907 \section2 Customizing SwipeDelegate
908
909 SwipeDelegate consists of six visual items: \l {Control::background}{background},
910 \l {Control::contentItem}{content item}, \l {AbstractButton::indicator}{indicator},
911 \c swipe.left, \c swipe.right, and \c swipe.behind.
912
913 \image qtquickcontrols-swipedelegate-custom.png
914
915 \snippet qtquickcontrols-swipedelegate-custom.qml file
916
917
918 \section2 Customizing SwipeView
919
920 SwipeView can have a visual \l {Control::background}{background}
921 item. The navigation is implemented by the \l {Control::contentItem}
922 {content item}.
923
924 \snippet qtquickcontrols-swipeview-custom.qml file
925
926
927 \section2 Customizing Switch
928
929 Switch consists of three visual items: \l {Control::background}{background},
930 \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
931
932 \image qtquickcontrols-switch-custom.png
933
934 \snippet qtquickcontrols-switch-custom.qml file
935
936 \section2 Customizing SwitchDelegate
937
938 SwitchDelegate consists of three visual items: \l {Control::background}{background},
939 \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
940
941 \image qtquickcontrols-switchdelegate-custom.png
942
943 \snippet qtquickcontrols-switchdelegate-custom.qml file
944
945
946 \section2 Customizing TabBar
947
948 TabBar consists of two visual items: \l {Control::background}{background},
949 and \l {Control::contentItem}{contentItem}.
950
951 \image qtquickcontrols-tabbar-custom.png
952
953 \snippet qtquickcontrols-tabbar-custom.qml file
954
955
956 \section2 Customizing TabButton
957
958 TabButton can be customized in the same manner as
959 \l {Customizing Button}{Button}.
960
961
962 \section2 Customizing TextArea
963
964 TextArea consists of a \l {TextArea::background}{background} item.
965
966 \image qtquickcontrols-textarea-custom.png
967
968 \snippet qtquickcontrols-textarea-custom.qml file
969
970
971 \section2 Customizing TextField
972
973 TextField consists of a \l {TextField::background}{background} item.
974
975 \image qtquickcontrols-textfield-custom.png
976
977 \snippet qtquickcontrols-textfield-custom.qml file
978
979
980 \section2 Customizing ToolBar
981
982 ToolBar consists of one visual item: \l {Control::background}{background}.
983
984 \image qtquickcontrols-toolbar-custom.png
985
986 \snippet qtquickcontrols-toolbar-custom.qml file
987
988
989 \section2 Customizing ToolButton
990
991 ToolButton consists of two visual items: \l {Control::background}{background}
992 and \l {Control::contentItem}{content item}.
993
994 \image qtquickcontrols-toolbutton-custom.png
995
996 \snippet qtquickcontrols-toolbutton-custom.qml file
997
998
999 \section2 Customizing ToolSeparator
1000
1001 ToolSeparator consists of two visual items: \l {Control::background}{background}
1002 and \l {Control::contentItem}{content item}.
1003
1004 \image qtquickcontrols-toolseparator-custom.png
1005
1006 \snippet qtquickcontrols-toolseparator-custom.qml file
1007
1008
1009 \section2 Customizing ToolTip
1010
1011 ToolTip consists of two visual items: \l {Popup::background}{background}
1012 and \l {Popup::contentItem}{content item}.
1013
1014 \quotefromfile qtquickcontrols-tooltip-custom.qml
1015 \skipto import QtQuick
1016 \printuntil import QtQuick.Controls
1017 \skipto ToolTip
1018 \printuntil }
1019 \printuntil }
1020 \printuntil }
1021
1022 \include qquicktooltip.qdocinc customize-note
1023
1024 \section2 Customizing Tumbler
1025
1026 Tumbler consists of three visual items:
1027 \l {Control::background}{background},
1028 \l {Control::contentItem}{contentItem}, and
1029 \l {Tumbler::delegate}{delegate}.
1030
1031 \image qtquickcontrols-tumbler-custom.png
1032
1033 \snippet qtquickcontrols-tumbler-custom.qml file
1034
1035 If you want to define your own contentItem, use either a \l ListView or
1036 \l PathView as the root item. For a wrapping Tumbler, use PathView:
1037
1038 \snippet qtquickcontrols-tumbler-pathView.qml contentItem
1039
1040 For a non-wrapping Tumbler, use ListView:
1041
1042 \snippet qtquickcontrols-tumbler-listView.qml contentItem
1043*/