Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qabstractbutton.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 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
4#include "private/qabstractbutton_p.h"
5
6#if QT_CONFIG(itemviews)
7#include "qabstractitemview.h"
8#endif
9#if QT_CONFIG(buttongroup)
10#include "qbuttongroup.h"
11#include "private/qbuttongroup_p.h"
12#endif
13#include "private/qapplication_p.h"
14#include "qabstractbutton_p.h"
15#include "qevent.h"
16#include "qpainter.h"
17#include "qapplication.h"
18#include "qstyle.h"
19#if QT_CONFIG(accessibility)
20#include "qaccessible.h"
21#endif
22#include <qpa/qplatformtheme.h>
23
24#include <algorithm>
25
27
28#define AUTO_REPEAT_DELAY 300
29#define AUTO_REPEAT_INTERVAL 100
30
31Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
32
137 :
138#ifndef QT_NO_SHORTCUT
139 shortcutId(0),
140#endif
141 checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
142 down(false), blockRefresh(false), pressed(false),
143#if QT_CONFIG(buttongroup)
144 group(nullptr),
145#endif
146 autoRepeatDelay(AUTO_REPEAT_DELAY),
147 autoRepeatInterval(AUTO_REPEAT_INTERVAL),
148 controlType(type)
149{}
150
152{
153#if QT_CONFIG(buttongroup)
154 if (group)
155 return group->d_func()->buttonList;
156#endif
157
158 if (!parent)
159 return {};
161 if (autoExclusive) {
162 auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) {
163 return !candidate->autoExclusive()
164#if QT_CONFIG(buttongroup)
165 || candidate->group()
166#endif
167 ;
168 };
169 candidates.removeIf(isNoMemberOfMyAutoExclusiveGroup);
170 }
171 return candidates;
172}
173
175{
176#if QT_CONFIG(buttongroup)
177 if (group)
178 return group->d_func()->checkedButton;
179#endif
180
181 Q_Q(const QAbstractButton);
183 if (!autoExclusive || buttonList.size() == 1) // no group
184 return nullptr;
185
186 for (int i = 0; i < buttonList.size(); ++i) {
187 QAbstractButton *b = buttonList.at(i);
188 if (b->d_func()->checked && b != q)
189 return b;
190 }
191 return checked ? const_cast<QAbstractButton *>(q) : nullptr;
192}
193
195{
196#if QT_CONFIG(buttongroup)
197 Q_Q(QAbstractButton);
198 if (group) {
199 QAbstractButton *previous = group->d_func()->checkedButton;
200 group->d_func()->checkedButton = q;
201 if (group->d_func()->exclusive && previous && previous != q)
202 previous->nextCheckState();
203 } else
204#endif
205 if (autoExclusive) {
207 b->setChecked(false);
208 }
209}
210
212{
214#if QT_CONFIG(buttongroup)
215 bool exclusive = group ? group->d_func()->exclusive : autoExclusive;
216#else
217 bool exclusive = autoExclusive;
218#endif
220 QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);
221 if (!fb || !buttonList.contains(fb))
222 return;
223
224 QAbstractButton *candidate = nullptr;
225 int bestScore = -1;
226 QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
227 QPoint goal = target.center();
229
230 for (int i = 0; i < buttonList.size(); ++i) {
231 QAbstractButton *button = buttonList.at(i);
232 if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() &&
233 (exclusive || (button->focusPolicy() & focus_flag) == focus_flag)) {
234 QRect buttonRect = button->rect().translated(button->mapToGlobal(QPoint(0,0)));
235 QPoint p = buttonRect.center();
236
237 //Priority to widgets that overlap on the same coordinate.
238 //In that case, the distance in the direction will be used as significant score,
239 //take also in account orthogonal distance in case two widget are in the same distance.
240 int score;
241 if ((buttonRect.x() < target.right() && target.x() < buttonRect.right())
242 && (key == Qt::Key_Up || key == Qt::Key_Down)) {
243 //one item's is at the vertical of the other
244 score = (qAbs(p.y() - goal.y()) << 16) + qAbs(p.x() - goal.x());
245 } else if ((buttonRect.y() < target.bottom() && target.y() < buttonRect.bottom())
246 && (key == Qt::Key_Left || key == Qt::Key_Right) ) {
247 //one item's is at the horizontal of the other
248 score = (qAbs(p.x() - goal.x()) << 16) + qAbs(p.y() - goal.y());
249 } else {
250 score = (1 << 30) + (p.y() - goal.y()) * (p.y() - goal.y()) + (p.x() - goal.x()) * (p.x() - goal.x());
251 }
252
253 if (score > bestScore && candidate)
254 continue;
255
256 switch(key) {
257 case Qt::Key_Up:
258 if (p.y() < goal.y()) {
259 candidate = button;
260 bestScore = score;
261 }
262 break;
263 case Qt::Key_Down:
264 if (p.y() > goal.y()) {
265 candidate = button;
266 bestScore = score;
267 }
268 break;
269 case Qt::Key_Left:
270 if (p.x() < goal.x()) {
271 candidate = button;
272 bestScore = score;
273 }
274 break;
275 case Qt::Key_Right:
276 if (p.x() > goal.x()) {
277 candidate = button;
278 bestScore = score;
279 }
280 break;
281 }
282 }
283 }
284
285 if (exclusive
286#ifdef QT_KEYPAD_NAVIGATION
287 && !QApplicationPrivate::keypadNavigationEnabled()
288#endif
289 && candidate
290 && fb->d_func()->checked
291 && candidate->d_func()->checkable)
292 candidate->click();
293
294 if (candidate) {
295 if (key == Qt::Key_Up || key == Qt::Key_Left)
297 else
298 candidate->setFocus(Qt::TabFocusReason);
299 }
300}
301
303{
304 Q_Q(QAbstractButton);
305#if QT_CONFIG(buttongroup)
306 if (!group && !autoExclusive)
307#else
308 if (!autoExclusive)
309#endif
310 return;
311
313 for (int i = 0; i < buttonList.size(); ++i) {
314 QAbstractButton *b = buttonList.at(i);
315 if (!b->isCheckable())
316 continue;
317 b->setFocusPolicy((Qt::FocusPolicy) ((b == q || !q->isCheckable())
318 ? (b->focusPolicy() | Qt::TabFocus)
319 : (b->focusPolicy() & ~Qt::TabFocus)));
320 }
321}
322
324{
325 Q_Q(QAbstractButton);
326
327 q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
329 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
330 q->setForegroundRole(QPalette::ButtonText);
331 q->setBackgroundRole(QPalette::Button);
332}
333
335{
336 Q_Q(QAbstractButton);
337
338 if (blockRefresh)
339 return;
340 q->update();
341}
342
344{
345 Q_Q(QAbstractButton);
346
347 down = false;
348 blockRefresh = true;
349 bool changeState = true;
350 if (checked && queryCheckedButton() == q) {
351 // the checked button of an exclusive or autoexclusive group cannot be unchecked
352#if QT_CONFIG(buttongroup)
353 if (group ? group->d_func()->exclusive : autoExclusive)
354#else
355 if (autoExclusive)
356#endif
357 changeState = false;
358 }
359
361 if (changeState) {
362 q->nextCheckState();
363 if (!guard)
364 return;
365 }
366 blockRefresh = false;
367 refresh();
368 q->repaint();
369 if (guard)
370 emitReleased();
371 if (guard)
372 emitClicked();
373}
374
376{
377 Q_Q(QAbstractButton);
379 emit q->clicked(checked);
380#if QT_CONFIG(buttongroup)
381 if (guard && group) {
382 emit group->idClicked(group->id(q));
383 if (guard && group)
384 emit group->buttonClicked(q);
385 }
386#endif
387}
388
390{
391 Q_Q(QAbstractButton);
393 emit q->pressed();
394#if QT_CONFIG(buttongroup)
395 if (guard && group) {
396 emit group->idPressed(group->id(q));
397 if (guard && group)
398 emit group->buttonPressed(q);
399 }
400#endif
401}
402
404{
405 Q_Q(QAbstractButton);
407 emit q->released();
408#if QT_CONFIG(buttongroup)
409 if (guard && group) {
410 emit group->idReleased(group->id(q));
411 if (guard && group)
412 emit group->buttonReleased(q);
413 }
414#endif
415}
416
418{
419 Q_Q(QAbstractButton);
421 emit q->toggled(checked);
422#if QT_CONFIG(buttongroup)
423 if (guard && group) {
424 emit group->idToggled(group->id(q), checked);
425 if (guard && group)
426 emit group->buttonToggled(q, checked);
427 }
428#endif
429}
430
436{
437 Q_D(QAbstractButton);
438 d->init();
439}
440
445{
446#if QT_CONFIG(buttongroup)
447 Q_D(QAbstractButton);
448 if (d->group)
449 d->group->removeButton(this);
450#endif
451}
452
453
457 : QWidget(dd, parent, { })
458{
459 Q_D(QAbstractButton);
460 d->init();
461}
462
481{
482 Q_D(QAbstractButton);
483 if (d->text == text)
484 return;
485 d->text = text;
486#ifndef QT_NO_SHORTCUT
488 setShortcut(newMnemonic);
489#endif
490 d->sizeHint = QSize();
491 update();
493#if QT_CONFIG(accessibility)
494 QAccessibleEvent event(this, QAccessible::NameChanged);
495 QAccessible::updateAccessibility(&event);
496#endif
497}
498
500{
501 Q_D(const QAbstractButton);
502 return d->text;
503}
504
505
514{
515 Q_D(QAbstractButton);
516 d->icon = icon;
517 d->sizeHint = QSize();
518 update();
520}
521
523{
524 Q_D(const QAbstractButton);
525 return d->icon;
526}
527
528#ifndef QT_NO_SHORTCUT
535{
536 Q_D(QAbstractButton);
537 if (d->shortcutId != 0)
538 releaseShortcut(d->shortcutId);
539 d->shortcut = key;
540 d->shortcutId = grabShortcut(key);
541}
542
544{
545 Q_D(const QAbstractButton);
546 return d->shortcut;
547}
548#endif // QT_NO_SHORTCUT
549
559{
560 Q_D(QAbstractButton);
561 if (d->checkable == checkable)
562 return;
563
564 d->checkable = checkable;
565 d->checked = false;
566}
567
569{
570 Q_D(const QAbstractButton);
571 return d->checkable;
572}
573
583{
584 Q_D(QAbstractButton);
585 if (!d->checkable || d->checked == checked) {
586 if (!d->blockRefresh)
588 return;
589 }
590
591 if (!checked && d->queryCheckedButton() == this) {
592 // the checked button of an exclusive or autoexclusive group cannot be unchecked
593#if QT_CONFIG(buttongroup)
594 if (d->group ? d->group->d_func()->exclusive : d->autoExclusive)
595 return;
596 if (d->group)
597 d->group->d_func()->detectCheckedButton();
598#else
599 if (d->autoExclusive)
600 return;
601#endif
602 }
603
604 QPointer<QAbstractButton> guard(this);
605
606 d->checked = checked;
607 if (!d->blockRefresh)
609 d->refresh();
610
611 if (guard && checked)
612 d->notifyChecked();
613 if (guard)
614 d->emitToggled(checked);
615
616#if QT_CONFIG(accessibility)
617 if (guard) {
619 s.checked = true;
620 QAccessibleStateChangeEvent event(this, s);
621 QAccessible::updateAccessibility(&event);
622 }
623#endif
624}
625
627{
628 Q_D(const QAbstractButton);
629 return d->checked;
630}
631
642{
643 Q_D(QAbstractButton);
644 if (d->down == down)
645 return;
646 d->down = down;
647 d->refresh();
648 if (d->autoRepeat && d->down)
649 d->repeatTimer.start(d->autoRepeatDelay, this);
650 else
651 d->repeatTimer.stop();
652}
653
655{
656 Q_D(const QAbstractButton);
657 return d->down;
658}
659
675{
676 Q_D(QAbstractButton);
677 if (d->autoRepeat == autoRepeat)
678 return;
679 d->autoRepeat = autoRepeat;
680 if (d->autoRepeat && d->down)
681 d->repeatTimer.start(d->autoRepeatDelay, this);
682 else
683 d->repeatTimer.stop();
684}
685
687{
688 Q_D(const QAbstractButton);
689 return d->autoRepeat;
690}
691
703void QAbstractButton::setAutoRepeatDelay(int autoRepeatDelay)
704{
705 Q_D(QAbstractButton);
706 d->autoRepeatDelay = autoRepeatDelay;
707}
708
710{
711 Q_D(const QAbstractButton);
712 return d->autoRepeatDelay;
713}
714
726void QAbstractButton::setAutoRepeatInterval(int autoRepeatInterval)
727{
728 Q_D(QAbstractButton);
729 d->autoRepeatInterval = autoRepeatInterval;
730}
731
733{
734 Q_D(const QAbstractButton);
735 return d->autoRepeatInterval;
736}
737
738
739
757void QAbstractButton::setAutoExclusive(bool autoExclusive)
758{
759 Q_D(QAbstractButton);
760 d->autoExclusive = autoExclusive;
761}
762
764{
765 Q_D(const QAbstractButton);
766 return d->autoExclusive;
767}
768
769#if QT_CONFIG(buttongroup)
778QButtonGroup *QAbstractButton::group() const
779{
780 Q_D(const QAbstractButton);
781 return d->group;
782}
783#endif // QT_CONFIG(buttongroup)
784
799{
800 if (!isEnabled())
801 return;
802 Q_D(QAbstractButton);
803 if (d->checkable && focusPolicy() & Qt::ClickFocus)
804 setFocus();
805 setDown(true);
806 repaint();
807 if (!d->animateTimer.isActive())
808 d->emitPressed();
809 d->animateTimer.start(100, this);
810}
811
824{
825 if (!isEnabled())
826 return;
827 Q_D(QAbstractButton);
828 QPointer<QAbstractButton> guard(this);
829 d->down = true;
830 d->emitPressed();
831 if (guard) {
832 d->down = false;
834 if (guard)
835 d->emitReleased();
836 if (guard)
837 d->emitClicked();
838 }
839}
840
848{
849 Q_D(QAbstractButton);
850 setChecked(!d->checked);
851}
852
853
861{
862}
863
872{
873 if (isCheckable())
875}
876
886{
887 return rect().contains(pos);
888}
889
892{
893 // as opposed to other widgets, disabled buttons accept mouse
894 // events. This avoids surprising click-through scenarios
895 if (!isEnabled()) {
896 switch(e->type()) {
908 return true;
909 default:
910 break;
911 }
912 }
913
914#ifndef QT_NO_SHORTCUT
915 if (e->type() == QEvent::Shortcut) {
916 Q_D(QAbstractButton);
917 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
918 if (d->shortcutId != se->shortcutId())
919 return false;
920 if (!se->isAmbiguous()) {
921 if (!d->animateTimer.isActive())
922 animateClick();
923 } else {
924 if (focusPolicy() != Qt::NoFocus)
927 }
928 return true;
929 }
930#endif
931 return QWidget::event(e);
932}
933
936{
937 Q_D(QAbstractButton);
938 if (e->button() != Qt::LeftButton) {
939 e->ignore();
940 return;
941 }
942 if (hitButton(e->position().toPoint())) {
943 setDown(true);
944 d->pressed = true;
945 repaint();
946 d->emitPressed();
947 e->accept();
948 } else {
949 e->ignore();
950 }
951}
952
955{
956 Q_D(QAbstractButton);
957
958 if (e->button() != Qt::LeftButton) {
959 e->ignore();
960 return;
961 }
962
963 d->pressed = false;
964
965 if (!d->down) {
966 // refresh is required by QMacStyle to resume the default button animation
967 d->refresh();
968 e->ignore();
969 return;
970 }
971
972 if (hitButton(e->position().toPoint())) {
973 d->repeatTimer.stop();
974 d->click();
975 e->accept();
976 } else {
977 setDown(false);
978 e->ignore();
979 }
980}
981
984{
985 Q_D(QAbstractButton);
986 if (!(e->buttons() & Qt::LeftButton) || !d->pressed) {
987 e->ignore();
988 return;
989 }
990
991 if (hitButton(e->position().toPoint()) != d->down) {
992 setDown(!d->down);
993 repaint();
994 if (d->down)
995 d->emitPressed();
996 else
997 d->emitReleased();
998 e->accept();
999 } else if (!hitButton(e->position().toPoint())) {
1000 e->ignore();
1001 }
1002}
1003
1006{
1007 Q_D(QAbstractButton);
1008 bool next = true;
1009
1010 const auto key = e->key();
1011 const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
1014 if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
1015 setDown(true);
1016 repaint();
1017 d->emitPressed();
1018 return;
1019 }
1020
1021 switch (key) {
1022 case Qt::Key_Up:
1023 next = false;
1024 Q_FALLTHROUGH();
1025 case Qt::Key_Left:
1026 case Qt::Key_Right:
1027 case Qt::Key_Down: {
1028#ifdef QT_KEYPAD_NAVIGATION
1029 if ((QApplicationPrivate::keypadNavigationEnabled()
1030 && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
1031 || (!QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
1032 || (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down))) {
1033 e->ignore();
1034 return;
1035 }
1036#endif
1037 QWidget *pw = parentWidget();
1038 if (d->autoExclusive
1039#if QT_CONFIG(buttongroup)
1040 || d->group
1041#endif
1042#if QT_CONFIG(itemviews)
1043 || (pw && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
1044#endif
1045 ) {
1046 // ### Using qobject_cast to check if the parent is a viewport of
1047 // QAbstractItemView is a crude hack, and should be revisited and
1048 // cleaned up when fixing task 194373. It's here to ensure that we
1049 // keep compatibility outside QAbstractItemView.
1050 d->moveFocus(e->key());
1051 if (hasFocus()) // nothing happened, propagate
1052 e->ignore();
1053 } else {
1054 // Prefer parent widget, use this if parent is absent
1055 QWidget *w = pw ? pw : this;
1056 bool reverse = (w->layoutDirection() == Qt::RightToLeft);
1057 if ((e->key() == Qt::Key_Left && !reverse)
1058 || (e->key() == Qt::Key_Right && reverse)) {
1059 next = false;
1060 }
1062 }
1063 break;
1064 }
1065 default:
1066#ifndef QT_NO_SHORTCUT
1067 if (e->matches(QKeySequence::Cancel) && d->down) {
1068 setDown(false);
1069 repaint();
1070 d->emitReleased();
1071 return;
1072 }
1073#endif
1074 e->ignore();
1075 }
1076}
1077
1080{
1081 Q_D(QAbstractButton);
1082
1083 if (!e->isAutoRepeat())
1084 d->repeatTimer.stop();
1085
1086 const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
1089 if (buttonPressKeys.contains(e->key()) && !e->isAutoRepeat() && d->down) {
1090 d->click();
1091 return;
1092 }
1093
1094 e->ignore();
1095}
1096
1100{
1101 Q_D(QAbstractButton);
1102 if (e->timerId() == d->repeatTimer.timerId()) {
1103 d->repeatTimer.start(d->autoRepeatInterval, this);
1104 if (d->down) {
1105 QPointer<QAbstractButton> guard(this);
1107 if (guard)
1108 d->emitReleased();
1109 if (guard)
1110 d->emitClicked();
1111 if (guard)
1112 d->emitPressed();
1113 }
1114 } else if (e->timerId() == d->animateTimer.timerId()) {
1115 d->animateTimer.stop();
1116 d->click();
1117 }
1118}
1119
1122{
1123 Q_D(QAbstractButton);
1124#ifdef QT_KEYPAD_NAVIGATION
1125 if (!QApplicationPrivate::keypadNavigationEnabled())
1126#endif
1127 d->fixFocusPolicy();
1129}
1130
1133{
1134 Q_D(QAbstractButton);
1135 if (e->reason() != Qt::PopupFocusReason && d->down) {
1136 d->down = false;
1137 d->emitReleased();
1138 }
1140}
1141
1144{
1145 Q_D(QAbstractButton);
1146 switch (e->type()) {
1148 if (!isEnabled() && d->down) {
1149 d->down = false;
1150 d->emitReleased();
1151 }
1152 break;
1153 default:
1154 d->sizeHint = QSize();
1155 break;
1156 }
1158}
1159
1233{
1234 Q_D(const QAbstractButton);
1235 if (d->iconSize.isValid())
1236 return d->iconSize;
1237 int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, nullptr, this);
1238 return QSize(e, e);
1239}
1240
1242{
1243 Q_D(QAbstractButton);
1244 if (d->iconSize == size)
1245 return;
1246
1247 d->iconSize = size;
1248 d->sizeHint = QSize();
1250 if (isVisible()) {
1251 update();
1252 }
1253}
1254
1255
1256
1258
1259#include "moc_qabstractbutton.cpp"
QList< QAbstractButton * > queryButtonList() const
QSizePolicy::ControlType controlType
QAbstractButton * queryCheckedButton() const
void emitToggled(bool checked)
QAbstractButtonPrivate(QSizePolicy::ControlType type=QSizePolicy::DefaultType)
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
bool down
whether the button is pressed down
void mouseMoveEvent(QMouseEvent *e) override
\reimp
void animateClick()
Performs an animated click: the button is pressed immediately, and released 100ms later.
int autoRepeatDelay
the initial delay of auto-repetition
QIcon icon
the icon shown on the button
void click()
Performs a click.
void mousePressEvent(QMouseEvent *e) override
\reimp
void setAutoRepeatDelay(int)
void mouseReleaseEvent(QMouseEvent *e) override
\reimp
void setAutoExclusive(bool)
bool checkable
whether the button is checkable
void focusInEvent(QFocusEvent *e) override
\reimp
bool isCheckable() const
void setShortcut(const QKeySequence &key)
void setIcon(const QIcon &icon)
bool event(QEvent *e) override
\reimp
bool autoRepeat
whether autoRepeat is enabled
void setAutoRepeatInterval(int)
int autoRepeatInterval
the interval of auto-repetition
bool checked
whether the button is checked
void toggle()
Toggles the state of a checkable button.
QKeySequence shortcut
the mnemonic associated with the button
void timerEvent(QTimerEvent *e) override
\reimp
~QAbstractButton()
Destroys the button.
bool autoExclusive
whether auto-exclusivity is enabled
QAbstractButton(QWidget *parent=nullptr)
Constructs an abstract button with a parent.
void setIconSize(const QSize &size)
void keyPressEvent(QKeyEvent *e) override
\reimp
void changeEvent(QEvent *e) override
\reimp
virtual void checkStateSet()
This virtual handler is called when setChecked() is used, unless it is called from within nextCheckSt...
void setText(const QString &text)
void keyReleaseEvent(QKeyEvent *e) override
\reimp
bool isChecked() const
QSize iconSize
the icon size used for this button.
void focusOutEvent(QFocusEvent *e) override
\reimp
virtual bool hitButton(const QPoint &pos) const
Returns true if pos is inside the clickable button rectangle; otherwise returns false.
virtual void nextCheckState()
This virtual handler is called when a button is clicked.
QString text
the text shown on the button
\inmodule QtGui
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
The QButtonGroup class provides a container to organize groups of button widgets.
\inmodule QtCore
Definition qcoreevent.h:45
@ TabletMove
Definition qcoreevent.h:121
@ EnabledChange
Definition qcoreevent.h:134
@ MouseMove
Definition qcoreevent.h:63
@ MouseButtonPress
Definition qcoreevent.h:60
@ HoverLeave
Definition qcoreevent.h:176
@ HoverEnter
Definition qcoreevent.h:175
@ TabletRelease
Definition qcoreevent.h:127
@ HoverMove
Definition qcoreevent.h:177
@ TabletPress
Definition qcoreevent.h:126
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ ContextMenu
Definition qcoreevent.h:119
@ MouseButtonRelease
Definition qcoreevent.h:61
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
static QPlatformTheme * platformTheme()
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:423
The QKeySequence class encapsulates a key sequence as used by shortcuts.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
qsizetype removeIf(Predicate pred)
Definition qlist.h:587
\inmodule QtGui
Definition qevent.h:195
QObject * parent
Definition qobject.h:61
QList< T > findChildren(const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
Definition qobject.h:140
@ ButtonText
Definition qpalette.h:51
virtual QVariant themeHint(ThemeHint hint) const
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:127
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:132
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:181
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:851
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:260
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:187
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:232
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:178
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
@ SH_Button_FocusPolicy
Definition qstyle.h:632
@ PM_ButtonIconSize
Definition qstyle.h:505
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
\inmodule QtCore
Definition qcoreevent.h:359
T value() const &
Definition qvariant.h:511
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
void repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the ...
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4320
void releaseShortcut(int id)
Removes the shortcut with the given id from Qt's shortcut system.
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition qwidget.h:877
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
QPointF mapToGlobal(const QPointF &) const
Translates the widget coordinate pos to global screen coordinates.
QPoint pos
the position of the widget within its parent widget
Definition qwidget.h:111
virtual void focusInEvent(QFocusEvent *event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition qwidget.cpp:9711
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab,...
Definition qwidget.cpp:6800
QRect rect
the internal geometry of the widget excluding any window frame
Definition qwidget.h:116
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
bool isEnabled() const
Definition qwidget.h:814
void update()
Updates the widget unless updates are disabled or the widget is hidden.
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9428
bool event(QEvent *event) override
This is the main event handler; it handles event event.
Definition qwidget.cpp:8912
int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context.
QStyle * style() const
Definition qwidget.cpp:2607
bool hasFocus() const
Definition qwidget.cpp:6471
virtual void focusOutEvent(QFocusEvent *event)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition qwidget.cpp:9737
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition qwidget.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
bool isVisible() const
Definition qwidget.h:874
QString text
QPushButton * button
[2]
double e
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
@ NavigationModeKeypadDirectional
@ LeftButton
Definition qnamespace.h:57
@ WA_KeyboardFocusChange
Definition qnamespace.h:343
@ WA_WState_OwnSizePolicy
Definition qnamespace.h:333
@ RightToLeft
FocusPolicy
Definition qnamespace.h:105
@ ClickFocus
Definition qnamespace.h:108
@ NoFocus
Definition qnamespace.h:106
@ TabFocus
Definition qnamespace.h:107
@ StrongFocus
Definition qnamespace.h:109
@ Key_Right
Definition qnamespace.h:674
@ Key_Left
Definition qnamespace.h:672
@ Key_Up
Definition qnamespace.h:673
@ Key_Down
Definition qnamespace.h:675
@ PopupFocusReason
@ BacktabFocusReason
@ TabFocusReason
@ ShortcutFocusReason
#define AUTO_REPEAT_DELAY
Q_WIDGETS_EXPORT bool qt_tab_all_widgets()
#define AUTO_REPEAT_INTERVAL
#define Q_FALLTHROUGH()
Q_WIDGETS_EXPORT bool qt_tab_all_widgets()
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLboolean GLboolean GLboolean b
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat f
GLenum type
GLboolean GLuint group
GLenum target
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
#define QT_CONFIG(feature)
#define emit
unsigned int uint
Definition qtypes.h:29
if(qFloatDistance(a, b)<(1<< 7))
[0]
QObject::connect nullptr
bool contains(const AT &t) const noexcept
Definition qlist.h:44
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent