Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqstylekitcontrols.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
7
9
10/*!
11 \qmltype StylableControls
12 \inqmlmodule Qt.labs.StyleKit
13 \brief Abstract base type containing the control types that can be styled.
14
15 StylableControls is an abstract base type. It contains a \l ControlStyle for
16 each control type that can be styled by a \l Style, \l Theme, or \l StyleVariation.
17
18 The control types form a hierarchy where properties set on a base type
19 propagate down to the more specific ones. For example, assigning a radius
20 of four to \c abstractButton.background.radius will cause all button
21 types, such as \l button, \l checkBox, and \l radioButton, to get a radius
22 of four.
23
24 The snippets on this page illustrate a few of the key properties that can be
25 used to style each control type, but they are by no means exhaustive. Many other properties
26 are available, as documented in the \l ControlStyle and \l DelegateStyle documentation.
27 In practice, some of them can also be omitted because the
28 \l {Style::fallbackStyle}{fallback style} already supplies sensible defaults.
29 This means that if you simply remove a property from one of the snippets, it
30 might not actually affect its appearance, since it will just be read from the
31 fallback style instead.
32
33 \sa {StyleKit Property Resolution}
34
35 \labs
36*/
37
38/*!
39 \qmlproperty ControlStyle StylableControls::control
40
41 Grouped property for styling all controls.
42
43 \c control is the base type in the control hierarchy, and properties set here
44 serve as defaults for all other control types. For example, setting
45 \c{control.width: 200} makes \e all controls 200 pixels wide,
46 including buttons, scroll indicators and every other control.
47 It also overrides any values inherited from a higher level in the style
48 hierarchy (the \l Style for a \l Theme, or the
49 \l {Style::fallbackStyle}{fallbackStyle} for a \l Style), \e including hover
50 effects and other state-based behavior. Use \c{control} sparingly, and
51 prefer more specific base types like \l abstractButton or \l pane when
52 possible.
53
54 \snippet ControlsSnippets.qml control
55*/
56
57/*!
58 \qmlproperty ControlStyle StylableControls::abstractButton
59
60 Grouped property for styling all button-like controls, including
61 \l [QtQuickControls]{Button}, \l [QtQuickControls]{CheckBox},
62 \l [QtQuickControls]{RadioButton}, \l [QtQuickControls]{Switch}
63 and \l [QtQuickControls]{RoundButton}.
64 Unset properties fall back to \l control.
65
66 \snippet ControlsSnippets.qml abstractButton
67
68 \sa {Qt Labs StyleKit}{Control Types}
69*/
70
71/*!
72 \qmlproperty ControlStyle StylableControls::applicationWindow
73
74 Grouped property for styling \l [QtQuickControls] ApplicationWindow.
75
76 Unset properties fall back to \l control.
77
78 Use \c applicationWindow to set the background color of the window:
79
80 \snippet ControlsSnippets.qml applicationWindow
81
82 \note The application needs to use ApplicationWindow, not Window, for this to take effect.
83*/
84
85/*!
86 \qmlproperty ControlStyle StylableControls::busyIndicator
87
88 Grouped property for styling \l [QtQuickControls]{BusyIndicator}.
89
90 Unset properties fall back to \l control.
91
92 \snippet ControlsSnippets.qml busyIndicator
93
94 StyleKit doesn't provide dedicated properties to style the animation of the
95 spinning indicator. To change the shape or animation of the spinning indicator,
96 you need to implement a custom indicator foreground \l {DelegateStyle::}{delegate}
97 instead:
98
99 \snippet ControlsSnippets.qml busyIndicator delegate
100*/
101
102/*!
103 \qmlproperty ControlStyle StylableControls::button
104
105 Grouped property for styling \l [QtQuickControls]{Button}.
106
107 Unset properties fall back to \l abstractButton.
108
109 \snippet ControlsSnippets.qml button
110*/
111
112/*!
113 \qmlproperty ControlStyle StylableControls::checkBox
114
115 Grouped property for styling \l [QtQuickControls]{CheckBox}.
116
117 Unset properties fall back to \l abstractButton.
118
119 \snippet ControlsSnippets.qml checkBox
120*/
121
122/*!
123 \qmlproperty ControlStyle StylableControls::checkDelegate
124
125 Grouped property for styling \l [QtQuickControls]{CheckDelegate}.
126
127 Unset properties fall back to \l itemDelegate.
128
129 \snippet ControlsSnippets.qml checkDelegate
130*/
131
132/*!
133 \qmlproperty ControlStyle StylableControls::comboBox
134
135 Grouped property for styling \l [QtQuickControls]{ComboBox}.
136
137 Unset properties fall back to \l control.
138
139 \note Style the popup through \l popup, and its items through \l itemDelegate.
140
141 \snippet ControlsSnippets.qml comboBox
142*/
143
144/*!
145 \qmlproperty ControlStyle StylableControls::delayButton
146
147 Grouped property for styling \l [QtQuickControls]{DelayButton}.
148
149 For a delay button, the progress is styled through the indicator. By
150 default, the indicator itself is transparent and without a border,
151 so only the indicator's foreground is visible as it fills up.
152
153 Unset properties fall back to \l abstractButton.
154
155 \snippet ControlsSnippets.qml delayButton
156*/
157
158/*!
159 \qmlproperty ControlStyle StylableControls::dial
160
161 Grouped property for styling \l [QtQuickControls]{Dial}.
162
163 Unset properties fall back to \l control.
164
165 \snippet ControlsSnippets.qml dial
166*/
167
168/*!
169 \qmlproperty ControlStyle StylableControls::dialog
170
171 Grouped property for styling \l [QtQuickControls]{Dialog}.
172
173 Unset properties fall back to \l popup.
174
175 \snippet ControlsSnippets.qml dialog
176*/
177
178/*!
179 \qmlproperty ControlStyle StylableControls::dialogButtonBox
180
181 Grouped property for styling \l [QtQuickControls]{DialogButtonBox}.
182
183 Unset properties fall back to \l pane.
184
185 \snippet ControlsSnippets.qml dialogButtonBox
186*/
187
188/*!
189 \qmlproperty ControlStyle StylableControls::drawer
190
191 Grouped property for styling \l [QtQuickControls]{Drawer}.
192
193 Unset properties fall back to \l popup.
194
195 \snippet ControlsSnippets.qml drawer
196*/
197
198/*!
199 \qmlproperty ControlStyle StylableControls::flatButton
200
201 Grouped property for styling flat buttons (buttons with no visible
202 background in their normal state). The styling will take effect for
203 a \l [QtQuickControls]{Button} if \l [QtQuickControls]{Button::flat}{Button.flat} is set to \c true.
204
205 Unset properties fall back to \l abstractButton.
206
207 \snippet ControlsSnippets.qml flatButton
208*/
209
210/*!
211 \qmlproperty ControlStyle StylableControls::frame
212
213 Grouped property for styling \l [QtQuickControls]{Frame}.
214
215 Unset properties fall back to \l pane.
216
217 \snippet ControlsSnippets.qml frame
218*/
219
220/*!
221 \qmlproperty ControlStyle StylableControls::groupBox
222
223 Grouped property for styling \l [QtQuickControls]{GroupBox}.
224
225 Unset properties fall back to \l frame.
226
227 \snippet ControlsSnippets.qml groupBox
228*/
229
230/*!
231 \qmlproperty ControlStyle StylableControls::itemDelegate
232
233 Grouped property for styling \l [QtQuickControls]{ItemDelegate}.
234
235 Unset properties fall back to \l control.
236
237 \note In Qt Quick Controls, \l [QtQuickControls]{ItemDelegate} inherits from
238 \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c itemDelegate
239 falls back to \l control rather than \l abstractButton, since delegates are
240 typically \e styled very differently from buttons (flat, no borders or drop shadows, etc.).
241
242 \snippet ControlsSnippets.qml itemDelegate
243*/
244
245/*!
246 \qmlproperty ControlStyle StylableControls::label
247
248 Grouped property for styling \l [QtQuickControls]{Label}.
249
250 Unset properties fall back to \l control.
251
252 \snippet ControlsSnippets.qml label
253*/
254
255/*!
256 \qmlproperty ControlStyle StylableControls::menu
257
258 Grouped property for styling \l [QtQuickControls]{Menu}.
259
260 Unset properties fall back to \l popup.
261
262 \snippet ControlsSnippets.qml menu
263*/
264
265/*!
266 \qmlproperty ControlStyle StylableControls::menuItem
267
268 Grouped property for styling \l [QtQuickControls]{MenuItem}.
269
270 Unset properties fall back to \l control.
271
272 \note In Qt Quick Controls, a \l [QtQuickControls]{MenuItem} inherits from
273    \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c menuItem
274 falls back to \l control instead of \l abstractButton, since menu items are
275 typically \e styled very differently from regular buttons
276 (flat, no borders or drop shadows, etc.).
277
278 \snippet ControlsSnippets.qml menuItem
279*/
280
281/*!
282 \qmlproperty ControlStyle StylableControls::menuBar
283
284 Grouped property for styling \l [QtQuickControls]{MenuBar}.
285
286 Unset properties fall back to \l control.
287
288 \note Styling \l [QtQuickControls]{MenuBar}, \l [QtQuickControls]{MenuBarItem},
289 and \l [QtQuickControls]{MenuSeparator} normally only affects non-native
290 menu bars. When a MenuBar is implemented as a native menu bar, its delegates
291 are not used for rendering, so StyleKit style properties may have no visual
292 effect. See \l [QtLabsPlatform]{MenuBar} {Native Menu Bars} for details.
293
294 \snippet ControlsSnippets.qml menuBar
295*/
296
297/*!
298 \qmlproperty ControlStyle StylableControls::menuBarItem
299
300 Grouped property for styling menu items in a \l [QtQuickControls]{MenuBar}.
301
302 Unset properties fall back to \l control.
303
304 \note In Qt Quick Controls, a \l [QtQuickControls]{MenuBarItem} inherits from
305 \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c menuBarItem is a
306 separate control type that falls back to \l control instead of \l abstractButton,
307 since menu bar items are typically styled very differently from regular buttons
308 (flat, no borders or drop shadows, etc.).
309
310 \snippet ControlsSnippets.qml menuBarItem
311*/
312
313/*!
314 \qmlproperty ControlStyle StylableControls::menuSeparator
315
316 Grouped property for styling \l [QtQuickControls]{MenuSeparator}.
317
318 Unset properties fall back to \l control.
319
320 \snippet ControlsSnippets.qml menuSeparator
321*/
322
323/*!
324 \qmlproperty ControlStyle StylableControls::page
325
326 Grouped property for styling \l [QtQuickControls]{Page}.
327
328 Unset properties fall back to \l pane.
329
330 Note that the \l [QtQuickControls]{Page::header}{header} and
331 \l [QtQuickControls]{Page::footer}{footer} of a \l [QtQuickControls]{Page} are
332 typically set by the application to a \l [QtQuickControls]{ToolBar} or
333 \l [QtQuickControls]{TabBar}, and those controls are styled separately.
334 To give a \l [QtQuickControls]{ToolBar} alternative styling when used inside
335 a \l [QtQuickControls]{Page}, use a \l StyleVariation:
336
337 \snippet ControlsSnippets.qml page
338*/
339
340/*!
341 \qmlproperty ControlStyle StylableControls::pageIndicator
342
343 Grouped property for styling \l [QtQuickControls]{PageIndicator}.
344
345 Unset properties fall back to \l control.
346
347 \snippet ControlsSnippets.qml pageIndicator
348*/
349
350/*!
351 \qmlproperty ControlStyle StylableControls::pane
352
353 Grouped property for styling \l [QtQuickControls]{Pane}.
354
355 Unset properties fall back to \l control.
356
357 \snippet ControlsSnippets.qml pane
358*/
359
360/*!
361 \qmlproperty ControlStyle StylableControls::popup
362
363 Grouped property for styling \l [QtQuickControls]{Popup}.
364
365 Unset properties fall back to \l control.
366
367 \snippet ControlsSnippets.qml popup
368*/
369
370/*!
371 \qmlproperty ControlStyle StylableControls::progressBar
372
373 Grouped property for styling \l [QtQuickControls]{ProgressBar}.
374 For a progress bar, the groove is styled through the indicator, while the progress
375 track is styled through the indicator's foreground.
376
377 Unset properties fall back to \l control.
378
379 \snippet ControlsSnippets.qml progressBar
380
381 StyleKit doesn't provide a dedicated property to style the indeterminate animation
382 of a progress bar. To change the animation, you need to implement a custom indicator
383 foreground \l {DelegateStyle::}{delegate} instead:
384
385 \snippet ControlsSnippets.qml progressBar indeterminate
386*/
387
388/*!
389 \qmlproperty ControlStyle StylableControls::radioButton
390
391 Grouped property for styling \l [QtQuickControls]{RadioButton}.
392
393 Unset properties fall back to \l abstractButton.
394
395 \snippet ControlsSnippets.qml radioButton
396*/
397
398/*!
399 \qmlproperty ControlStyle StylableControls::radioDelegate
400
401 Grouped property for styling \l [QtQuickControls]{RadioDelegate}.
402
403 Unset properties fall back to \l itemDelegate.
404
405 \snippet ControlsSnippets.qml radioDelegate
406*/
407
408/*!
409 \qmlproperty ControlStyle StylableControls::roundButton
410
411 Grouped property for styling \l [QtQuickControls]{RoundButton}.
412
413 Unset properties fall back to \l abstractButton.
414
415 \snippet ControlsSnippets.qml roundButton
416*/
417
418/*!
419 \qmlproperty ControlStyle StylableControls::scrollBar
420
421 Grouped property for styling \l [QtQuickControls]{ScrollBar}.
422 The groove is styled through \l {ControlStyleProperties::}{background}, and the
423 handle through \l {ControlStyleProperties::}{indicator}.
424
425 Unset properties fall back to \l control.
426
427 \snippet ControlsSnippets.qml scrollBar
428*/
429
430/*!
431 \qmlproperty ControlStyle StylableControls::scrollIndicator
432
433 Grouped property for styling \l [QtQuickControls]{ScrollIndicator}.
434 The groove is styled through \l {ControlStyleProperties::}{background}, and the
435 handle through \l {ControlStyleProperties::}{indicator}.
436
437 Unset properties fall back to \l control.
438
439 \snippet ControlsSnippets.qml scrollIndicator
440*/
441
442/*!
443 \qmlproperty ControlStyle StylableControls::scrollView
444
445 Grouped property for styling \l [QtQuickControls]{ScrollView}.
446
447 ScrollView itself has no visual delegates to style. Its scroll bars can be
448 styled separately through the \l scrollBar property. But you can use
449 \l {ControlStateStyle::padding}{padding} to control the space between
450 the scroll bars and the content area.
451
452 Unset properties fall back to \l control.
453
454 \snippet ControlsSnippets.qml scrollView
455*/
456
457/*!
458 \qmlproperty ControlStyle StylableControls::searchField
459
460 Grouped property for styling \l [QtQuickControls]{SearchField}.
461
462 Unset properties fall back to \l control.
463
464 \snippet ControlsSnippets.qml searchField
465
466*/
467
468/*!
469 \qmlproperty ControlStyle StylableControls::slider
470
471 Grouped property for styling \l [QtQuickControls]{Slider}.
472 For a slider, the groove is styled through the indicator, while the progress
473 track is styled through the indicator's foreground.
474
475 Unset properties fall back to \l control.
476
477 For vertical sliders, swap the \l {DelegateStyle::width}{width}
478 and \l {DelegateStyle::height}{height} of the relevant delegates
479 so that the control is taller than it is wide, as shown in the snippet below.
480
481 \snippet ControlsSnippets.qml slider
482*/
483
484/*!
485 \qmlproperty ControlStyle StylableControls::spinBox
486
487 Grouped property for styling \l [QtQuickControls]{SpinBox}.
488
489 Unset properties fall back to \l control.
490
491 \snippet ControlsSnippets.qml spinBox
492
493 \note It's currently only possible to position the up and down buttons to
494 be on the left or right side of the control, but not on top of each other.
495*/
496
497/*!
498 \qmlproperty ControlStyle StylableControls::swipeDelegate
499
500 Grouped property for styling \l [QtQuickControls]{SwipeDelegate}.
501
502 Unset properties fall back to \l itemDelegate.
503
504 \snippet ControlsSnippets.qml swipeDelegate
505*/
506
507/*!
508 \qmlproperty ControlStyle StylableControls::switchControl
509
510 Grouped property for styling \l [QtQuickControls]{Switch}.
511
512 Unset properties fall back to \l abstractButton.
513
514 \snippet ControlsSnippets.qml switchControl
515*/
516
517/*!
518 \qmlproperty ControlStyle StylableControls::switchDelegate
519
520 Grouped property for styling \l [QtQuickControls]{SwitchDelegate}.
521
522 Unset properties fall back to \l itemDelegate.
523
524 \snippet ControlsSnippets.qml switchDelegate
525*/
526
527/*!
528 \qmlproperty ControlStyle StylableControls::tabBar
529
530 Grouped property for styling \l [QtQuickControls]{TabBar}.
531
532 Unset properties fall back to \l pane.
533
534 \snippet ControlsSnippets.qml tabBar
535*/
536
537/*!
538 \qmlproperty ControlStyle StylableControls::tabButton
539
540 Grouped property for styling \l [QtQuickControls]{TabButton}.
541
542 Unset properties fall back to \l abstractButton.
543
544 \snippet ControlsSnippets.qml tabButton
545*/
546
547/*!
548 \qmlproperty ControlStyle StylableControls::textArea
549
550 Grouped property for styling \l [QtQuickControls]{TextArea}.
551
552 Unset properties fall back to \l textInput.
553
554 \snippet ControlsSnippets.qml textArea
555*/
556
557/*!
558 \qmlproperty ControlStyle StylableControls::textField
559
560 Grouped property for styling \l [QtQuickControls]{TextField}.
561
562 Unset properties fall back to \l textInput.
563
564 \snippet ControlsSnippets.qml textField
565*/
566
567/*!
568 \qmlproperty ControlStyle StylableControls::textInput
569
570 Grouped property for styling all text input controls, including
571 \l [QtQuickControls]{TextField} and \l [QtQuickControls]{TextArea}.
572
573 Unset properties fall back to \l control.
574
575 \snippet ControlsSnippets.qml textInput
576*/
577
578/*!
579 \qmlproperty ControlStyle StylableControls::toolBar
580
581 Grouped property for styling \l [QtQuickControls]{ToolBar}.
582
583 Unset properties fall back to \l pane.
584
585 \snippet ControlsSnippets.qml toolBar
586*/
587
588/*!
589 \qmlproperty ControlStyle StylableControls::toolButton
590
591 Grouped property for styling \l [QtQuickControls]{ToolButton}.
592
593 Unset properties fall back to \l abstractButton.
594
595 \snippet ControlsSnippets.qml toolButton
596*/
597
598/*!
599 \qmlproperty ControlStyle StylableControls::toolSeparator
600
601 Grouped property for styling \l [QtQuickControls]{ToolSeparator}.
602
603 Unset properties fall back to \l control.
604
605 For vertical separators, swap the \l {DelegateStyle::width}{width}
606 and \l {DelegateStyle::height}{height} of the relevant delegates
607 so that the control is taller than it is wide, as shown in the snippet below.
608
609 \snippet ControlsSnippets.qml toolSeparator
610*/
611
612/*!
613 \qmlproperty ControlStyle StylableControls::toolTip
614
615 Grouped property for styling \l [QtQuickControls]{ToolTip}.
616
617 Unset properties fall back to \l popup.
618
619 \snippet ControlsSnippets.qml toolTip
620*/
621
622/*!
623 \qmlproperty ControlStyle StylableControls::tumbler
624
625 Grouped property for styling \l [QtQuickControls]{Tumbler}.
626
627 Unset properties fall back to \l control.
628
629 \snippet ControlsSnippets.qml tumbler
630*/
631
632using namespace Qt::StringLiterals;
633
634QQStyleKitControls::QQStyleKitControls(QObject *parent)
635 : QObject(parent)
636{
637}
638
640{
641 return QQmlListProperty<QObject>(this, &m_data);
642}
643
645{
646 return m_data;
647}
648
649/*!
650 \qmlmethod ControlStyle StylableControls::getControlStyle(controlType)
651
652 Returns the \l ControlStyle for the given \a controlType, or \c null, if
653 no \l ControlStyle for the type has been defined.
654
655 \a controlType can be one of the built-in types documented by
656 \l {StyleReader::controlType}{StyleReader.controlType}, or the
657 \l {CustomControl::controlType}{controlType} of a \l CustomControl.
658
659 This function can be used to, for example, read or write a property on
660 a \l CustomControl's style at runtime:
661
662 \snippet ControlsSnippets.qml getControlStyle
663
664 \snippet ControlsSnippets.qml getControlStyle-function
665
666 If \a controlType is a built-in type (such as \c {StyleReader.Button}),
667 using for example \c {myStyle.button} or \c {myStyle.getControlStyle(StyleReader.Button)}
668 to get the \l ControlStyle is \e almost equivalent.
669 The difference is that the former will lazily create a \l ControlStyle if
670 it's not yet defined, while the latter will instead return \c null.
671 This means that for example \c {myStyle.button.padding = 10} is always
672 safe, while \c {myStyle.getControlStyle(StyleReader.Button).padding = 10} will
673 fail if \c {myStyle.button} has not been defined in the \l Style.
674
675 \sa CustomControl, StyleReader
676*/
677
678/* Lazy-create the controls that the style is actually using, when accessed
679 * from the style/application (e.g from Style or Theme). We don't lazy
680 * create any controls while resolving style properties, as undefined controls would
681 * anyway not contain any property overrides. The properties have setters too, to
682 * allow the style/application to share custom ControlStyle the classical
683 * way, e.g button: ControlStyle { id: button }. */
684QQStyleKitControl* QQStyleKitControls::getControlStyle(QQStyleKitExtendableControlType controlType) const
685{
686 return m_controls.value(controlType, nullptr);
687}
688
689#define IMPLEMENT_ACCESSORS(NAME, TYPE) QQStyleKitControl
690 *QQStyleKitControls::NAME() const \
691{
692 if (!m_controls.contains(TYPE)) {
693 auto *self = const_cast<QQStyleKitControls *>(this);
694 auto *control = new QQStyleKitControl(self);
695 self->m_controls.insert(TYPE, control);
696 }
697 return m_controls[TYPE]; \
698}void
699 QQStyleKitControls::set_ ## NAME(QQStyleKitControl *control) \
700{
701 m_controls.insert(TYPE, control); \
702}
703
704
705IMPLEMENT_ACCESSORS(abstractButton, QQStyleKitReader::ControlType::AbstractButton)
706IMPLEMENT_ACCESSORS(applicationWindow, QQStyleKitReader::ControlType::ApplicationWindow)
707IMPLEMENT_ACCESSORS(control, QQStyleKitReader::ControlType::Control)
708IMPLEMENT_ACCESSORS(busyIndicator, QQStyleKitReader::ControlType::BusyIndicator)
709IMPLEMENT_ACCESSORS(button, QQStyleKitReader::ControlType::Button)
710IMPLEMENT_ACCESSORS(flatButton, QQStyleKitReader::ControlType::FlatButton)
711IMPLEMENT_ACCESSORS(checkBox, QQStyleKitReader::ControlType::CheckBox)
712IMPLEMENT_ACCESSORS(checkDelegate, QQStyleKitReader::ControlType::CheckDelegate)
713IMPLEMENT_ACCESSORS(comboBox, QQStyleKitReader::ControlType::ComboBox)
714IMPLEMENT_ACCESSORS(delayButton, QQStyleKitReader::ControlType::DelayButton)
715IMPLEMENT_ACCESSORS(dial, QQStyleKitReader::ControlType::Dial)
716IMPLEMENT_ACCESSORS(dialog, QQStyleKitReader::ControlType::Dialog)
717IMPLEMENT_ACCESSORS(dialogButtonBox, QQStyleKitReader::ControlType::DialogButtonBox)
718IMPLEMENT_ACCESSORS(drawer, QQStyleKitReader::ControlType::Drawer)
719IMPLEMENT_ACCESSORS(progressBar, QQStyleKitReader::ControlType::ProgressBar)
720IMPLEMENT_ACCESSORS(scrollBar, QQStyleKitReader::ControlType::ScrollBar)
721IMPLEMENT_ACCESSORS(scrollIndicator, QQStyleKitReader::ControlType::ScrollIndicator)
722IMPLEMENT_ACCESSORS(scrollView, QQStyleKitReader::ControlType::ScrollView)
723IMPLEMENT_ACCESSORS(searchField, QQStyleKitReader::SearchField)
724IMPLEMENT_ACCESSORS(slider, QQStyleKitReader::ControlType::Slider)
725IMPLEMENT_ACCESSORS(spinBox, QQStyleKitReader::ControlType::SpinBox)
726IMPLEMENT_ACCESSORS(swipeDelegate, QQStyleKitReader::ControlType::SwipeDelegate)
727IMPLEMENT_ACCESSORS(switchControl, QQStyleKitReader::ControlType::SwitchControl)
728IMPLEMENT_ACCESSORS(switchDelegate, QQStyleKitReader::ControlType::SwitchDelegate)
729IMPLEMENT_ACCESSORS(tabBar, QQStyleKitReader::ControlType::TabBar)
730IMPLEMENT_ACCESSORS(tabButton, QQStyleKitReader::ControlType::TabButton)
731IMPLEMENT_ACCESSORS(textField, QQStyleKitReader::ControlType::TextField)
732IMPLEMENT_ACCESSORS(textInput, QQStyleKitReader::ControlType::TextInput)
733IMPLEMENT_ACCESSORS(toolBar, QQStyleKitReader::ControlType::ToolBar)
734IMPLEMENT_ACCESSORS(toolButton, QQStyleKitReader::ControlType::ToolButton)
735IMPLEMENT_ACCESSORS(toolSeparator, QQStyleKitReader::ControlType::ToolSeparator)
736IMPLEMENT_ACCESSORS(toolTip, QQStyleKitReader::ControlType::ToolTip)
737IMPLEMENT_ACCESSORS(tumbler, QQStyleKitReader::ControlType::Tumbler)
738IMPLEMENT_ACCESSORS(radioButton, QQStyleKitReader::ControlType::RadioButton)
739IMPLEMENT_ACCESSORS(radioDelegate, QQStyleKitReader::ControlType::RadioDelegate)
740IMPLEMENT_ACCESSORS(roundButton, QQStyleKitReader::ControlType::RoundButton)
741IMPLEMENT_ACCESSORS(itemDelegate, QQStyleKitReader::ControlType::ItemDelegate)
742IMPLEMENT_ACCESSORS(popup, QQStyleKitReader::ControlType::Popup)
743IMPLEMENT_ACCESSORS(pane, QQStyleKitReader::ControlType::Pane)
744IMPLEMENT_ACCESSORS(page, QQStyleKitReader::ControlType::Page)
745IMPLEMENT_ACCESSORS(pageIndicator, QQStyleKitReader::ControlType::PageIndicator)
746IMPLEMENT_ACCESSORS(frame, QQStyleKitReader::ControlType::Frame)
747IMPLEMENT_ACCESSORS(label, QQStyleKitReader::ControlType::Label)
748IMPLEMENT_ACCESSORS(groupBox, QQStyleKitReader::ControlType::GroupBox)
749IMPLEMENT_ACCESSORS(textArea, QQStyleKitReader::ControlType::TextArea)
750IMPLEMENT_ACCESSORS(menu, QQStyleKitReader::ControlType::Menu)
751IMPLEMENT_ACCESSORS(menuBar, QQStyleKitReader::ControlType::MenuBar)
752IMPLEMENT_ACCESSORS(menuBarItem, QQStyleKitReader::ControlType::MenuBarItem)
753IMPLEMENT_ACCESSORS(menuItem, QQStyleKitReader::ControlType::MenuItem)
754IMPLEMENT_ACCESSORS(menuSeparator, QQStyleKitReader::ControlType::MenuSeparator)
755
756#undef IMPLEMENT_ACCESSORS
757
759{
760 for (auto *obj : children()) {
761 if (auto *customControl = qobject_cast<QQStyleKitCustomControl *>(obj)) {
762 const QQStyleKitExtendableControlType type = customControl->controlType();
763 const QQStyleKitExtendableControlType reserved
764 = QQStyleKitExtendableControlType(QQStyleKitReader::ControlType::Unspecified);
765 if (type >= reserved)
766 qmlWarning(this) << "CustomControls must use a controlType less than " << reserved;
767 if (m_controls.contains(type))
768 qmlWarning(this) << "CustomControl registered more than once: " << type;
769 m_controls.insert(type, customControl);
770 }
771 }
772}
773
774QT_END_NAMESPACE
775
776#include "moc_qqstylekitcontrols_p.cpp"
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
const QList< QObject * > children() const
QQmlListProperty< QObject > data()
Combined button and popup list for selecting options.
#define IMPLEMENT_ACCESSORS(NAME, TYPE)