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