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 AbstractStylableControls
12 \inqmlmodule Qt.labs.StyleKit
13 \brief Abstract base type containing the control types that can be styled.
14
15 AbstractControls 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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::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 AbstractStylableControls::dialog
160
161 Grouped property for styling \l [QtQuickControls]{Dialog}.
162
163 Unset properties fall back to \l popup.
164
165 \snippet ControlsSnippets.qml dialog
166*/
167
168/*!
169 \qmlproperty ControlStyle AbstractStylableControls::dialogButtonBox
170
171 Grouped property for styling \l [QtQuickControls]{DialogButtonBox}.
172
173 Unset properties fall back to \l pane.
174
175 \snippet ControlsSnippets.qml dialogButtonBox
176*/
177
178/*!
179 \qmlproperty ControlStyle AbstractStylableControls::flatButton
180
181 Grouped property for styling flat buttons (buttons with no visible
182 background in their normal state). The styling will take effect for
183 a \l [QtQuickControls]{Button} if \l [QtQuickControls]{Button::flat}{Button.flat} is set to \c true.
184
185 Unset properties fall back to \l abstractButton.
186
187 \snippet ControlsSnippets.qml flatButton
188*/
189
190/*!
191 \qmlproperty ControlStyle AbstractStylableControls::frame
192
193 Grouped property for styling \l [QtQuickControls]{Frame}.
194
195 Unset properties fall back to \l pane.
196
197 \snippet ControlsSnippets.qml frame
198*/
199
200/*!
201 \qmlproperty ControlStyle AbstractStylableControls::groupBox
202
203 Grouped property for styling \l [QtQuickControls]{GroupBox}.
204
205 Unset properties fall back to \l frame.
206
207 \snippet ControlsSnippets.qml groupBox
208*/
209
210/*!
211 \qmlproperty ControlStyle AbstractStylableControls::itemDelegate
212
213 Grouped property for styling \l [QtQuickControls]{ItemDelegate}.
214
215 Unset properties fall back to \l control.
216
217 \note In Qt Quick Controls, \l [QtQuickControls]{ItemDelegate} inherits from
218 \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c itemDelegate
219 falls back to \l control rather than \l abstractButton, since delegates are
220 typically \e styled very differently from buttons (flat, no borders or drop shadows, etc.).
221
222 \snippet ControlsSnippets.qml itemDelegate
223*/
224
225/*!
226 \qmlproperty ControlStyle AbstractStylableControls::label
227
228 Grouped property for styling \l [QtQuickControls]{Label}.
229
230 Unset properties fall back to \l control.
231
232 \snippet ControlsSnippets.qml label
233*/
234
235/*!
236 \qmlproperty ControlStyle AbstractStylableControls::menu
237
238 Grouped property for styling \l [QtQuickControls]{Menu}.
239
240 Unset properties fall back to \l popup.
241
242 \snippet ControlsSnippets.qml menu
243*/
244
245/*!
246 \qmlproperty ControlStyle AbstractStylableControls::menuItem
247
248 Grouped property for styling \l [QtQuickControls]{MenuItem}.
249
250 Unset properties fall back to \l control.
251
252 \note In Qt Quick Controls, a \l [QtQuickControls]{MenuItem} inherits from
253    \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c menuItem
254 falls back to \l control instead of \l abstractButton, since menu items are
255 typically \e styled very differently from regular buttons
256 (flat, no borders or drop shadows, etc.).
257
258 \snippet ControlsSnippets.qml menuItem
259*/
260
261/*!
262 \qmlproperty ControlStyle AbstractStylableControls::menuBar
263
264 Grouped property for styling \l [QtQuickControls]{MenuBar}.
265
266 Unset properties fall back to \l control.
267
268 \note Styling \l [QtQuickControls]{MenuBar}, \l [QtQuickControls]{MenuBarItem},
269 and \l [QtQuickControls]{MenuSeparator} normally only affects non-native
270 menu bars. When a MenuBar is implemented as a native menu bar, its delegates
271 are not used for rendering, so StyleKit style properties may have no visual
272 effect. See \l [QtLabsPlatform]{MenuBar} {Native Menu Bars} for details.
273
274 \snippet ControlsSnippets.qml menuBar
275*/
276
277/*!
278 \qmlproperty ControlStyle AbstractStylableControls::menuBarItem
279
280 Grouped property for styling menu items in a \l [QtQuickControls]{MenuBar}.
281
282 Unset properties fall back to \l control.
283
284 \note In Qt Quick Controls, a \l [QtQuickControls]{MenuBarItem} inherits from
285 \l [QtQuickControls]{AbstractButton}. In StyleKit, however, \c menuBarItem is a
286 separate control type that falls back to \l control instead of \l abstractButton,
287 since menu bar items are typically styled very differently from regular buttons
288 (flat, no borders or drop shadows, etc.).
289
290 \snippet ControlsSnippets.qml menuBarItem
291*/
292
293/*!
294 \qmlproperty ControlStyle AbstractStylableControls::menuSeparator
295
296 Grouped property for styling \l [QtQuickControls]{MenuSeparator}.
297
298 Unset properties fall back to \l control.
299
300 \snippet ControlsSnippets.qml menuSeparator
301*/
302
303/*!
304 \qmlproperty ControlStyle AbstractStylableControls::page
305
306 Grouped property for styling \l [QtQuickControls]{Page}.
307
308 Unset properties fall back to \l pane.
309
310 Note that the \l [QtQuickControls]{Page::header}{header} and
311 \l [QtQuickControls]{Page::footer}{footer} of a \l [QtQuickControls]{Page} are
312 typically set by the application to a \l [QtQuickControls]{ToolBar} or
313 \l [QtQuickControls]{TabBar}, and those controls are styled separately.
314 To give a \l [QtQuickControls]{ToolBar} alternative styling when used inside
315 a \l [QtQuickControls]{Page}, use a \l StyleVariation:
316
317 \snippet ControlsSnippets.qml page
318*/
319
320/*!
321 \qmlproperty ControlStyle AbstractStylableControls::pageIndicator
322
323 Grouped property for styling \l [QtQuickControls]{PageIndicator}.
324
325 Unset properties fall back to \l control.
326
327 \snippet ControlsSnippets.qml pageIndicator
328*/
329
330/*!
331 \qmlproperty ControlStyle AbstractStylableControls::pane
332
333 Grouped property for styling \l [QtQuickControls]{Pane}.
334
335 Unset properties fall back to \l control.
336
337 \snippet ControlsSnippets.qml pane
338*/
339
340/*!
341 \qmlproperty ControlStyle AbstractStylableControls::popup
342
343 Grouped property for styling \l [QtQuickControls]{Popup}.
344
345 Unset properties fall back to \l control.
346
347 \snippet ControlsSnippets.qml popup
348*/
349
350/*!
351 \qmlproperty ControlStyle AbstractStylableControls::progressBar
352
353 Grouped property for styling \l [QtQuickControls]{ProgressBar}.
354 For a progress bar, the groove is styled through the indicator, while the progress
355 track is styled through the indicator's foreground.
356
357 Unset properties fall back to \l control.
358
359 \snippet ControlsSnippets.qml progressBar
360
361 StyleKit doesn't provide a dedicated property to style the indeterminate animation
362 of a progress bar. To change the animation, you need to implement a custom indicator
363 foreground \l {DelegateStyle::}{delegate} instead:
364
365 \snippet ControlsSnippets.qml progressBar indeterminate
366*/
367
368/*!
369 \qmlproperty ControlStyle AbstractStylableControls::radioButton
370
371 Grouped property for styling \l [QtQuickControls]{RadioButton}.
372
373 Unset properties fall back to \l abstractButton.
374
375 \snippet ControlsSnippets.qml radioButton
376*/
377
378/*!
379 \qmlproperty ControlStyle AbstractStylableControls::radioDelegate
380
381 Grouped property for styling \l [QtQuickControls]{RadioDelegate}.
382
383 Unset properties fall back to \l itemDelegate.
384
385 \snippet ControlsSnippets.qml radioDelegate
386*/
387
388/*!
389 \qmlproperty ControlStyle AbstractStylableControls::roundButton
390
391 Grouped property for styling \l [QtQuickControls]{RoundButton}.
392
393 Unset properties fall back to \l abstractButton.
394
395 \snippet ControlsSnippets.qml roundButton
396*/
397
398/*!
399 \qmlproperty ControlStyle AbstractStylableControls::scrollBar
400
401 Grouped property for styling \l [QtQuickControls]{ScrollBar}.
402 The groove is styled through \l {ControlStyleProperties::}{background}, and the
403 handle through \l {ControlStyleProperties::}{indicator}.
404
405 Unset properties fall back to \l control.
406
407 \snippet ControlsSnippets.qml scrollBar
408*/
409
410/*!
411 \qmlproperty ControlStyle AbstractStylableControls::scrollIndicator
412
413 Grouped property for styling \l [QtQuickControls]{ScrollIndicator}.
414 The groove is styled through \l {ControlStyleProperties::}{background}, and the
415 handle through \l {ControlStyleProperties::}{indicator}.
416
417 Unset properties fall back to \l control.
418
419 \snippet ControlsSnippets.qml scrollIndicator
420*/
421
422/*!
423 \qmlproperty ControlStyle AbstractStylableControls::scrollView
424
425 Grouped property for styling \l [QtQuickControls]{ScrollView}.
426
427 ScrollView itself has no visual delegates to style. Its scroll bars can be
428 styled separately through the \l scrollBar property. But you can use
429 \l {ControlStateStyle::padding}{padding} to control the space between
430 the scroll bars and the content area.
431
432 Unset properties fall back to \l control.
433
434 \snippet ControlsSnippets.qml scrollView
435*/
436
437/*!
438 \qmlproperty ControlStyle AbstractStylableControls::searchField
439
440 Grouped property for styling \l [QtQuickControls]{SearchField}.
441
442 Unset properties fall back to \l control.
443
444 \snippet ControlsSnippets.qml searchField
445
446*/
447
448/*!
449 \qmlproperty ControlStyle AbstractStylableControls::slider
450
451 Grouped property for styling \l [QtQuickControls]{Slider}.
452 For a slider, the groove is styled through the indicator, while the progress
453 track is styled through the indicator's foreground.
454
455 Unset properties fall back to \l control.
456
457 For vertical sliders, swap the \l {DelegateStyle::width}{width}
458 and \l {DelegateStyle::height}{height} of the relevant delegates
459 so that the control is taller than it is wide, as shown in the snippet below.
460
461 \snippet ControlsSnippets.qml slider
462*/
463
464/*!
465 \qmlproperty ControlStyle AbstractStylableControls::spinBox
466
467 Grouped property for styling \l [QtQuickControls]{SpinBox}.
468
469 Unset properties fall back to \l control.
470
471 \snippet ControlsSnippets.qml spinBox
472
473 \note It's currently only possible to position the up and down buttons to
474 be on the left or right side of the control, but not on top of each other.
475*/
476
477/*!
478 \qmlproperty ControlStyle AbstractStylableControls::swipeDelegate
479
480 Grouped property for styling \l [QtQuickControls]{SwipeDelegate}.
481
482 Unset properties fall back to \l itemDelegate.
483
484 \snippet ControlsSnippets.qml swipeDelegate
485*/
486
487/*!
488 \qmlproperty ControlStyle AbstractStylableControls::switchControl
489
490 Grouped property for styling \l [QtQuickControls]{Switch}.
491
492 Unset properties fall back to \l abstractButton.
493
494 \snippet ControlsSnippets.qml switchControl
495*/
496
497/*!
498 \qmlproperty ControlStyle AbstractStylableControls::switchDelegate
499
500 Grouped property for styling \l [QtQuickControls]{SwitchDelegate}.
501
502 Unset properties fall back to \l itemDelegate.
503
504 \snippet ControlsSnippets.qml switchDelegate
505*/
506
507/*!
508 \qmlproperty ControlStyle AbstractStylableControls::tabBar
509
510 Grouped property for styling \l [QtQuickControls]{TabBar}.
511
512 Unset properties fall back to \l pane.
513
514 \snippet ControlsSnippets.qml tabBar
515*/
516
517/*!
518 \qmlproperty ControlStyle AbstractStylableControls::tabButton
519
520 Grouped property for styling \l [QtQuickControls]{TabButton}.
521
522 Unset properties fall back to \l abstractButton.
523
524 \snippet ControlsSnippets.qml tabButton
525*/
526
527/*!
528 \qmlproperty ControlStyle AbstractStylableControls::textArea
529
530 Grouped property for styling \l [QtQuickControls]{TextArea}.
531
532 Unset properties fall back to \l textInput.
533
534 \snippet ControlsSnippets.qml textArea
535*/
536
537/*!
538 \qmlproperty ControlStyle AbstractStylableControls::textField
539
540 Grouped property for styling \l [QtQuickControls]{TextField}.
541
542 Unset properties fall back to \l textInput.
543
544 \snippet ControlsSnippets.qml textField
545*/
546
547/*!
548 \qmlproperty ControlStyle AbstractStylableControls::textInput
549
550 Grouped property for styling all text input controls, including
551 \l [QtQuickControls]{TextField} and \l [QtQuickControls]{TextArea}.
552
553 Unset properties fall back to \l control.
554
555 \snippet ControlsSnippets.qml textInput
556*/
557
558/*!
559 \qmlproperty ControlStyle AbstractStylableControls::toolBar
560
561 Grouped property for styling \l [QtQuickControls]{ToolBar}.
562
563 Unset properties fall back to \l pane.
564
565 \snippet ControlsSnippets.qml toolBar
566*/
567
568/*!
569 \qmlproperty ControlStyle AbstractStylableControls::toolButton
570
571 Grouped property for styling \l [QtQuickControls]{ToolButton}.
572
573 Unset properties fall back to \l abstractButton.
574
575 \snippet ControlsSnippets.qml toolButton
576*/
577
578/*!
579 \qmlproperty ControlStyle AbstractStylableControls::toolSeparator
580
581 Grouped property for styling \l [QtQuickControls]{ToolSeparator}.
582
583 Unset properties fall back to \l control.
584
585 For vertical separators, swap the \l {DelegateStyle::width}{width}
586 and \l {DelegateStyle::height}{height} of the relevant delegates
587 so that the control is taller than it is wide, as shown in the snippet below.
588
589 \snippet ControlsSnippets.qml toolSeparator
590*/
591
592using namespace Qt::StringLiterals;
593
594QQStyleKitControls::QQStyleKitControls(QObject *parent)
595 : QObject(parent)
596{
597}
598
600{
601 return QQmlListProperty<QObject>(this, &m_data);
602}
603
605{
606 return m_data;
607}
608
609/*!
610 \qmlmethod ControlStyle AbstractStylableControls::getControlStyle(controlType)
611
612 Returns the \l ControlStyle for the given \a controlType, or \c null, if
613 no \l ControlStyle for the type has been defined.
614
615 \a controlType can be one of the built-in types documented by
616 \l {StyleReader::controlType}{StyleReader.controlType}, or the
617 \l {CustomControl::controlType}{controlType} of a \l CustomControl.
618
619 This function can be used to, for example, read or write a property on
620 a \l CustomControl's style at runtime:
621
622 \snippet ControlsSnippets.qml getControlStyle
623
624 \snippet ControlsSnippets.qml getControlStyle-function
625
626 If \a controlType is a built-in type (such as \c {StyleReader.Button}),
627 using for example \c {myStyle.button} or \c {myStyle.getControlStyle(StyleReader.Button)}
628 to get the \l ControlStyle is \e almost equivalent.
629 The difference is that the former will lazily create a \l ControlStyle if
630 it's not yet defined, while the latter will instead return \c null.
631 This means that for example \c {myStyle.button.padding = 10} is always
632 safe, while \c {myStyle.getControlStyle(StyleReader.Button).padding = 10} will
633 fail if \c {myStyle.button} has not been defined in the \l Style.
634
635 \sa CustomControl, StyleReader
636*/
637
638/* Lazy-create the controls that the style is actually using, when accessed
639 * from the style/application (e.g from Style or Theme). We don't lazy
640 * create any controls while resolving style properties, as undefined controls would
641 * anyway not contain any property overrides. The properties have setters too, to
642 * allow the style/application to share custom ControlStyle the classical
643 * way, e.g button: ControlStyle { id: button }. */
644QQStyleKitControl* QQStyleKitControls::getControlStyle(QQStyleKitExtendableControlType controlType) const
645{
646 return m_controls.value(controlType, nullptr);
647}
648
649#define IMPLEMENT_ACCESSORS(NAME, TYPE) QQStyleKitControl
650 *QQStyleKitControls::NAME() const \
651{
652 if (!m_controls.contains(TYPE)) {
653 auto *self = const_cast<QQStyleKitControls *>(this);
654 auto *control = new QQStyleKitControl(self);
655 self->m_controls.insert(TYPE, control);
656 }
657 return m_controls[TYPE]; \
658}void
659 QQStyleKitControls::set_ ## NAME(QQStyleKitControl *control) \
660{
661 m_controls.insert(TYPE, control); \
662}
663
664
665IMPLEMENT_ACCESSORS(abstractButton, QQStyleKitReader::ControlType::AbstractButton)
666IMPLEMENT_ACCESSORS(applicationWindow, QQStyleKitReader::ControlType::ApplicationWindow)
667IMPLEMENT_ACCESSORS(control, QQStyleKitReader::ControlType::Control)
668IMPLEMENT_ACCESSORS(busyIndicator, QQStyleKitReader::ControlType::BusyIndicator)
669IMPLEMENT_ACCESSORS(button, QQStyleKitReader::ControlType::Button)
670IMPLEMENT_ACCESSORS(flatButton, QQStyleKitReader::ControlType::FlatButton)
671IMPLEMENT_ACCESSORS(checkBox, QQStyleKitReader::ControlType::CheckBox)
672IMPLEMENT_ACCESSORS(checkDelegate, QQStyleKitReader::ControlType::CheckDelegate)
673IMPLEMENT_ACCESSORS(comboBox, QQStyleKitReader::ControlType::ComboBox)
674IMPLEMENT_ACCESSORS(delayButton, QQStyleKitReader::ControlType::DelayButton)
675IMPLEMENT_ACCESSORS(dialog, QQStyleKitReader::ControlType::Dialog)
676IMPLEMENT_ACCESSORS(dialogButtonBox, QQStyleKitReader::ControlType::DialogButtonBox)
677IMPLEMENT_ACCESSORS(progressBar, QQStyleKitReader::ControlType::ProgressBar)
678IMPLEMENT_ACCESSORS(scrollBar, QQStyleKitReader::ControlType::ScrollBar)
679IMPLEMENT_ACCESSORS(scrollIndicator, QQStyleKitReader::ControlType::ScrollIndicator)
680IMPLEMENT_ACCESSORS(scrollView, QQStyleKitReader::ControlType::ScrollView)
681IMPLEMENT_ACCESSORS(searchField, QQStyleKitReader::SearchField)
682IMPLEMENT_ACCESSORS(slider, QQStyleKitReader::ControlType::Slider)
683IMPLEMENT_ACCESSORS(spinBox, QQStyleKitReader::ControlType::SpinBox)
684IMPLEMENT_ACCESSORS(swipeDelegate, QQStyleKitReader::ControlType::SwipeDelegate)
685IMPLEMENT_ACCESSORS(switchControl, QQStyleKitReader::ControlType::SwitchControl)
686IMPLEMENT_ACCESSORS(switchDelegate, QQStyleKitReader::ControlType::SwitchDelegate)
687IMPLEMENT_ACCESSORS(tabBar, QQStyleKitReader::ControlType::TabBar)
688IMPLEMENT_ACCESSORS(tabButton, QQStyleKitReader::ControlType::TabButton)
689IMPLEMENT_ACCESSORS(textField, QQStyleKitReader::ControlType::TextField)
690IMPLEMENT_ACCESSORS(textInput, QQStyleKitReader::ControlType::TextInput)
691IMPLEMENT_ACCESSORS(toolBar, QQStyleKitReader::ControlType::ToolBar)
692IMPLEMENT_ACCESSORS(toolButton, QQStyleKitReader::ControlType::ToolButton)
693IMPLEMENT_ACCESSORS(toolSeparator, QQStyleKitReader::ControlType::ToolSeparator)
694IMPLEMENT_ACCESSORS(radioButton, QQStyleKitReader::ControlType::RadioButton)
695IMPLEMENT_ACCESSORS(radioDelegate, QQStyleKitReader::ControlType::RadioDelegate)
696IMPLEMENT_ACCESSORS(roundButton, QQStyleKitReader::ControlType::RoundButton)
697IMPLEMENT_ACCESSORS(itemDelegate, QQStyleKitReader::ControlType::ItemDelegate)
698IMPLEMENT_ACCESSORS(popup, QQStyleKitReader::ControlType::Popup)
699IMPLEMENT_ACCESSORS(pane, QQStyleKitReader::ControlType::Pane)
700IMPLEMENT_ACCESSORS(page, QQStyleKitReader::ControlType::Page)
701IMPLEMENT_ACCESSORS(pageIndicator, QQStyleKitReader::ControlType::PageIndicator)
702IMPLEMENT_ACCESSORS(frame, QQStyleKitReader::ControlType::Frame)
703IMPLEMENT_ACCESSORS(label, QQStyleKitReader::ControlType::Label)
704IMPLEMENT_ACCESSORS(groupBox, QQStyleKitReader::ControlType::GroupBox)
705IMPLEMENT_ACCESSORS(textArea, QQStyleKitReader::ControlType::TextArea)
706IMPLEMENT_ACCESSORS(menu, QQStyleKitReader::ControlType::Menu)
707IMPLEMENT_ACCESSORS(menuBar, QQStyleKitReader::ControlType::MenuBar)
708IMPLEMENT_ACCESSORS(menuBarItem, QQStyleKitReader::ControlType::MenuBarItem)
709IMPLEMENT_ACCESSORS(menuItem, QQStyleKitReader::ControlType::MenuItem)
710IMPLEMENT_ACCESSORS(menuSeparator, QQStyleKitReader::ControlType::MenuSeparator)
711
712#undef IMPLEMENT_ACCESSORS
713
715{
716 for (auto *obj : children()) {
717 if (auto *customControl = qobject_cast<QQStyleKitCustomControl *>(obj)) {
718 const QQStyleKitExtendableControlType type = customControl->controlType();
719 const QQStyleKitExtendableControlType reserved
720 = QQStyleKitExtendableControlType(QQStyleKitReader::ControlType::Unspecified);
721 if (type >= reserved)
722 qmlWarning(this) << "CustomControls must use a controlType less than " << reserved;
723 if (m_controls.contains(type))
724 qmlWarning(this) << "CustomControl registered more than once: " << type;
725 m_controls.insert(type, customControl);
726 }
727 }
728}
729
730QT_END_NAMESPACE
731
732#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)