QtBase  v6.3.1
qabstractbutton.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "private/qabstractbutton_p.h"
41 
42 #if QT_CONFIG(itemviews)
43 #include "qabstractitemview.h"
44 #endif
45 #if QT_CONFIG(buttongroup)
46 #include "qbuttongroup.h"
47 #include "private/qapplication_p.h"
48 #include "private/qbuttongroup_p.h"
49 #endif
50 #include "qabstractbutton_p.h"
51 #include "qevent.h"
52 #include "qpainter.h"
53 #include "qapplication.h"
54 #include "qstyle.h"
55 #ifndef QT_NO_ACCESSIBILITY
56 #include "qaccessible.h"
57 #endif
58 
59 #include <algorithm>
60 
62 
63 #define AUTO_REPEAT_DELAY 300
64 #define AUTO_REPEAT_INTERVAL 100
65 
66 Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
67 
172  :
173 #ifndef QT_NO_SHORTCUT
174  shortcutId(0),
175 #endif
176  checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
177  down(false), blockRefresh(false), pressed(false),
178 #if QT_CONFIG(buttongroup)
179  group(nullptr),
180 #endif
181  autoRepeatDelay(AUTO_REPEAT_DELAY),
182  autoRepeatInterval(AUTO_REPEAT_INTERVAL),
183  controlType(type)
184 {}
185 
187 {
188 #if QT_CONFIG(buttongroup)
189  if (group)
190  return group->d_func()->buttonList;
191 #endif
192 
193  if (!parent)
194  return {};
196  if (autoExclusive) {
197  auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) {
198  return !candidate->autoExclusive()
199 #if QT_CONFIG(buttongroup)
200  || candidate->group()
201 #endif
202  ;
203  };
204  candidates.removeIf(isNoMemberOfMyAutoExclusiveGroup);
205  }
206  return candidates;
207 }
208 
210 {
211 #if QT_CONFIG(buttongroup)
212  if (group)
213  return group->d_func()->checkedButton;
214 #endif
215 
216  Q_Q(const QAbstractButton);
218  if (!autoExclusive || buttonList.count() == 1) // no group
219  return nullptr;
220 
221  for (int i = 0; i < buttonList.count(); ++i) {
222  QAbstractButton *b = buttonList.at(i);
223  if (b->d_func()->checked && b != q)
224  return b;
225  }
226  return checked ? const_cast<QAbstractButton *>(q) : nullptr;
227 }
228 
230 {
231 #if QT_CONFIG(buttongroup)
232  Q_Q(QAbstractButton);
233  if (group) {
234  QAbstractButton *previous = group->d_func()->checkedButton;
235  group->d_func()->checkedButton = q;
236  if (group->d_func()->exclusive && previous && previous != q)
237  previous->nextCheckState();
238  } else
239 #endif
240  if (autoExclusive) {
242  b->setChecked(false);
243  }
244 }
245 
247 {
249 #if QT_CONFIG(buttongroup)
250  bool exclusive = group ? group->d_func()->exclusive : autoExclusive;
251 #else
252  bool exclusive = autoExclusive;
253 #endif
255  QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);
256  if (!fb || !buttonList.contains(fb))
257  return;
258 
259  QAbstractButton *candidate = nullptr;
260  int bestScore = -1;
261  QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
262  QPoint goal = target.center();
264 
265  for (int i = 0; i < buttonList.count(); ++i) {
266  QAbstractButton *button = buttonList.at(i);
267  if (button != f && button->window() == f->window() && button->isEnabled() && !button->isHidden() &&
268  (exclusive || (button->focusPolicy() & focus_flag) == focus_flag)) {
269  QRect buttonRect = button->rect().translated(button->mapToGlobal(QPoint(0,0)));
270  QPoint p = buttonRect.center();
271 
272  //Priority to widgets that overlap on the same coordinate.
273  //In that case, the distance in the direction will be used as significant score,
274  //take also in account orthogonal distance in case two widget are in the same distance.
275  int score;
276  if ((buttonRect.x() < target.right() && target.x() < buttonRect.right())
277  && (key == Qt::Key_Up || key == Qt::Key_Down)) {
278  //one item's is at the vertical of the other
279  score = (qAbs(p.y() - goal.y()) << 16) + qAbs(p.x() - goal.x());
280  } else if ((buttonRect.y() < target.bottom() && target.y() < buttonRect.bottom())
281  && (key == Qt::Key_Left || key == Qt::Key_Right) ) {
282  //one item's is at the horizontal of the other
283  score = (qAbs(p.x() - goal.x()) << 16) + qAbs(p.y() - goal.y());
284  } else {
285  score = (1 << 30) + (p.y() - goal.y()) * (p.y() - goal.y()) + (p.x() - goal.x()) * (p.x() - goal.x());
286  }
287 
288  if (score > bestScore && candidate)
289  continue;
290 
291  switch(key) {
292  case Qt::Key_Up:
293  if (p.y() < goal.y()) {
294  candidate = button;
295  bestScore = score;
296  }
297  break;
298  case Qt::Key_Down:
299  if (p.y() > goal.y()) {
300  candidate = button;
301  bestScore = score;
302  }
303  break;
304  case Qt::Key_Left:
305  if (p.x() < goal.x()) {
306  candidate = button;
307  bestScore = score;
308  }
309  break;
310  case Qt::Key_Right:
311  if (p.x() > goal.x()) {
312  candidate = button;
313  bestScore = score;
314  }
315  break;
316  }
317  }
318  }
319 
320  if (exclusive
321 #ifdef QT_KEYPAD_NAVIGATION
322  && !QApplicationPrivate::keypadNavigationEnabled()
323 #endif
324  && candidate
325  && fb->d_func()->checked
326  && candidate->d_func()->checkable)
327  candidate->click();
328 
329  if (candidate) {
330  if (key == Qt::Key_Up || key == Qt::Key_Left)
331  candidate->setFocus(Qt::BacktabFocusReason);
332  else
333  candidate->setFocus(Qt::TabFocusReason);
334  }
335 }
336 
338 {
339  Q_Q(QAbstractButton);
340 #if QT_CONFIG(buttongroup)
341  if (!group && !autoExclusive)
342 #else
343  if (!autoExclusive)
344 #endif
345  return;
346 
348  for (int i = 0; i < buttonList.count(); ++i) {
349  QAbstractButton *b = buttonList.at(i);
350  if (!b->isCheckable())
351  continue;
352  b->setFocusPolicy((Qt::FocusPolicy) ((b == q || !q->isCheckable())
353  ? (b->focusPolicy() | Qt::TabFocus)
354  : (b->focusPolicy() & ~Qt::TabFocus)));
355  }
356 }
357 
359 {
360  Q_Q(QAbstractButton);
361 
362  q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy)));
364  q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
365  q->setForegroundRole(QPalette::ButtonText);
366  q->setBackgroundRole(QPalette::Button);
367 }
368 
370 {
371  Q_Q(QAbstractButton);
372 
373  if (blockRefresh)
374  return;
375  q->update();
376 }
377 
379 {
380  Q_Q(QAbstractButton);
381 
382  down = false;
383  blockRefresh = true;
384  bool changeState = true;
385  if (checked && queryCheckedButton() == q) {
386  // the checked button of an exclusive or autoexclusive group cannot be unchecked
387 #if QT_CONFIG(buttongroup)
388  if (group ? group->d_func()->exclusive : autoExclusive)
389 #else
390  if (autoExclusive)
391 #endif
392  changeState = false;
393  }
394 
396  if (changeState) {
397  q->nextCheckState();
398  if (!guard)
399  return;
400  }
401  blockRefresh = false;
402  refresh();
403  q->repaint();
404  if (guard)
405  emitReleased();
406  if (guard)
407  emitClicked();
408 }
409 
411 {
412  Q_Q(QAbstractButton);
414  emit q->clicked(checked);
415 #if QT_CONFIG(buttongroup)
416  if (guard && group) {
417  emit group->idClicked(group->id(q));
418  if (guard && group)
419  emit group->buttonClicked(q);
420  }
421 #endif
422 }
423 
425 {
426  Q_Q(QAbstractButton);
428  emit q->pressed();
429 #if QT_CONFIG(buttongroup)
430  if (guard && group) {
431  emit group->idPressed(group->id(q));
432  if (guard && group)
433  emit group->buttonPressed(q);
434  }
435 #endif
436 }
437 
439 {
440  Q_Q(QAbstractButton);
442  emit q->released();
443 #if QT_CONFIG(buttongroup)
444  if (guard && group) {
445  emit group->idReleased(group->id(q));
446  if (guard && group)
447  emit group->buttonReleased(q);
448  }
449 #endif
450 }
451 
453 {
454  Q_Q(QAbstractButton);
456  emit q->toggled(checked);
457 #if QT_CONFIG(buttongroup)
458  if (guard && group) {
459  emit group->idToggled(group->id(q), checked);
460  if (guard && group)
461  emit group->buttonToggled(q, checked);
462  }
463 #endif
464 }
465 
471 {
472  Q_D(QAbstractButton);
473  d->init();
474 }
475 
480 {
481 #if QT_CONFIG(buttongroup)
482  Q_D(QAbstractButton);
483  if (d->group)
484  d->group->removeButton(this);
485 #endif
486 }
487 
488 
492  : QWidget(dd, parent, { })
493 {
494  Q_D(QAbstractButton);
495  d->init();
496 }
497 
516 {
517  Q_D(QAbstractButton);
518  if (d->text == text)
519  return;
520  d->text = text;
521 #ifndef QT_NO_SHORTCUT
523  setShortcut(newMnemonic);
524 #endif
525  d->sizeHint = QSize();
526  update();
527  updateGeometry();
528 #ifndef QT_NO_ACCESSIBILITY
531 #endif
532 }
533 
535 {
536  Q_D(const QAbstractButton);
537  return d->text;
538 }
539 
540 
549 {
550  Q_D(QAbstractButton);
551  d->icon = icon;
552  d->sizeHint = QSize();
553  update();
554  updateGeometry();
555 }
556 
558 {
559  Q_D(const QAbstractButton);
560  return d->icon;
561 }
562 
563 #ifndef QT_NO_SHORTCUT
570 {
571  Q_D(QAbstractButton);
572  if (d->shortcutId != 0)
573  releaseShortcut(d->shortcutId);
574  d->shortcut = key;
575  d->shortcutId = grabShortcut(key);
576 }
577 
579 {
580  Q_D(const QAbstractButton);
581  return d->shortcut;
582 }
583 #endif // QT_NO_SHORTCUT
584 
593 void QAbstractButton::setCheckable(bool checkable)
594 {
595  Q_D(QAbstractButton);
596  if (d->checkable == checkable)
597  return;
598 
599  d->checkable = checkable;
600  d->checked = false;
601 }
602 
604 {
605  Q_D(const QAbstractButton);
606  return d->checkable;
607 }
608 
617 void QAbstractButton::setChecked(bool checked)
618 {
619  Q_D(QAbstractButton);
620  if (!d->checkable || d->checked == checked) {
621  if (!d->blockRefresh)
622  checkStateSet();
623  return;
624  }
625 
626  if (!checked && d->queryCheckedButton() == this) {
627  // the checked button of an exclusive or autoexclusive group cannot be unchecked
628 #if QT_CONFIG(buttongroup)
629  if (d->group ? d->group->d_func()->exclusive : d->autoExclusive)
630  return;
631  if (d->group)
632  d->group->d_func()->detectCheckedButton();
633 #else
634  if (d->autoExclusive)
635  return;
636 #endif
637  }
638 
639  QPointer<QAbstractButton> guard(this);
640 
641  d->checked = checked;
642  if (!d->blockRefresh)
643  checkStateSet();
644  d->refresh();
645 
646  if (guard && checked)
647  d->notifyChecked();
648  if (guard)
649  d->emitToggled(checked);
650 
651 
652 #ifndef QT_NO_ACCESSIBILITY
654  s.checked = true;
657 #endif
658 }
659 
661 {
662  Q_D(const QAbstractButton);
663  return d->checked;
664 }
665 
676 {
677  Q_D(QAbstractButton);
678  if (d->down == down)
679  return;
680  d->down = down;
681  d->refresh();
682  if (d->autoRepeat && d->down)
683  d->repeatTimer.start(d->autoRepeatDelay, this);
684  else
685  d->repeatTimer.stop();
686 }
687 
689 {
690  Q_D(const QAbstractButton);
691  return d->down;
692 }
693 
708 void QAbstractButton::setAutoRepeat(bool autoRepeat)
709 {
710  Q_D(QAbstractButton);
711  if (d->autoRepeat == autoRepeat)
712  return;
713  d->autoRepeat = autoRepeat;
714  if (d->autoRepeat && d->down)
715  d->repeatTimer.start(d->autoRepeatDelay, this);
716  else
717  d->repeatTimer.stop();
718 }
719 
721 {
722  Q_D(const QAbstractButton);
723  return d->autoRepeat;
724 }
725 
737 void QAbstractButton::setAutoRepeatDelay(int autoRepeatDelay)
738 {
739  Q_D(QAbstractButton);
740  d->autoRepeatDelay = autoRepeatDelay;
741 }
742 
744 {
745  Q_D(const QAbstractButton);
746  return d->autoRepeatDelay;
747 }
748 
760 void QAbstractButton::setAutoRepeatInterval(int autoRepeatInterval)
761 {
762  Q_D(QAbstractButton);
763  d->autoRepeatInterval = autoRepeatInterval;
764 }
765 
767 {
768  Q_D(const QAbstractButton);
769  return d->autoRepeatInterval;
770 }
771 
772 
773 
791 void QAbstractButton::setAutoExclusive(bool autoExclusive)
792 {
793  Q_D(QAbstractButton);
794  d->autoExclusive = autoExclusive;
795 }
796 
798 {
799  Q_D(const QAbstractButton);
800  return d->autoExclusive;
801 }
802 
803 #if QT_CONFIG(buttongroup)
813 {
814  Q_D(const QAbstractButton);
815  return d->group;
816 }
817 #endif // QT_CONFIG(buttongroup)
818 
833 {
834  if (!isEnabled())
835  return;
836  Q_D(QAbstractButton);
837  if (d->checkable && focusPolicy() & Qt::ClickFocus)
838  setFocus();
839  setDown(true);
840  repaint();
841  if (!d->animateTimer.isActive())
842  d->emitPressed();
843  d->animateTimer.start(100, this);
844 }
845 
858 {
859  if (!isEnabled())
860  return;
861  Q_D(QAbstractButton);
862  QPointer<QAbstractButton> guard(this);
863  d->down = true;
864  d->emitPressed();
865  if (guard) {
866  d->down = false;
867  nextCheckState();
868  if (guard)
869  d->emitReleased();
870  if (guard)
871  d->emitClicked();
872  }
873 }
874 
882 {
883  Q_D(QAbstractButton);
884  setChecked(!d->checked);
885 }
886 
887 
895 {
896 }
897 
906 {
907  if (isCheckable())
908  setChecked(!isChecked());
909 }
910 
920 {
921  return rect().contains(pos);
922 }
923 
926 {
927  // as opposed to other widgets, disabled buttons accept mouse
928  // events. This avoids surprising click-through scenarios
929  if (!isEnabled()) {
930  switch(e->type()) {
931  case QEvent::TabletPress:
933  case QEvent::TabletMove:
937  case QEvent::MouseMove:
938  case QEvent::HoverMove:
939  case QEvent::HoverEnter:
940  case QEvent::HoverLeave:
941  case QEvent::ContextMenu:
942 #if QT_CONFIG(wheelevent)
943  case QEvent::Wheel:
944 #endif
945  return true;
946  default:
947  break;
948  }
949  }
950 
951 #ifndef QT_NO_SHORTCUT
952  if (e->type() == QEvent::Shortcut) {
953  Q_D(QAbstractButton);
954  QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
955  if (d->shortcutId != se->shortcutId())
956  return false;
957  if (!se->isAmbiguous()) {
958  if (!d->animateTimer.isActive())
959  animateClick();
960  } else {
961  if (focusPolicy() != Qt::NoFocus)
964  }
965  return true;
966  }
967 #endif
968  return QWidget::event(e);
969 }
970 
973 {
974  Q_D(QAbstractButton);
975  if (e->button() != Qt::LeftButton) {
976  e->ignore();
977  return;
978  }
979  if (hitButton(e->position().toPoint())) {
980  setDown(true);
981  d->pressed = true;
982  repaint();
983  d->emitPressed();
984  e->accept();
985  } else {
986  e->ignore();
987  }
988 }
989 
992 {
993  Q_D(QAbstractButton);
994 
995  if (e->button() != Qt::LeftButton) {
996  e->ignore();
997  return;
998  }
999 
1000  d->pressed = false;
1001 
1002  if (!d->down) {
1003  // refresh is required by QMacStyle to resume the default button animation
1004  d->refresh();
1005  e->ignore();
1006  return;
1007  }
1008 
1009  if (hitButton(e->position().toPoint())) {
1010  d->repeatTimer.stop();
1011  d->click();
1012  e->accept();
1013  } else {
1014  setDown(false);
1015  e->ignore();
1016  }
1017 }
1018 
1021 {
1022  Q_D(QAbstractButton);
1023  if (!(e->buttons() & Qt::LeftButton) || !d->pressed) {
1024  e->ignore();
1025  return;
1026  }
1027 
1028  if (hitButton(e->position().toPoint()) != d->down) {
1029  setDown(!d->down);
1030  repaint();
1031  if (d->down)
1032  d->emitPressed();
1033  else
1034  d->emitReleased();
1035  e->accept();
1036  } else if (!hitButton(e->position().toPoint())) {
1037  e->ignore();
1038  }
1039 }
1040 
1043 {
1044  Q_D(QAbstractButton);
1045  bool next = true;
1046  switch (e->key()) {
1047  case Qt::Key_Enter:
1048  case Qt::Key_Return:
1049  e->ignore();
1050  break;
1051  case Qt::Key_Select:
1052  case Qt::Key_Space:
1053  if (!e->isAutoRepeat()) {
1054  setDown(true);
1055  repaint();
1056  d->emitPressed();
1057  }
1058  break;
1059  case Qt::Key_Up:
1060  next = false;
1061  Q_FALLTHROUGH();
1062  case Qt::Key_Left:
1063  case Qt::Key_Right:
1064  case Qt::Key_Down: {
1065 #ifdef QT_KEYPAD_NAVIGATION
1066  if ((QApplicationPrivate::keypadNavigationEnabled()
1067  && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
1068  || (!QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
1069  || (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down))) {
1070  e->ignore();
1071  return;
1072  }
1073 #endif
1074  QWidget *pw = parentWidget();
1075  if (d->autoExclusive
1076 #if QT_CONFIG(buttongroup)
1077  || d->group
1078 #endif
1079 #if QT_CONFIG(itemviews)
1080  || (pw && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
1081 #endif
1082  ) {
1083  // ### Using qobject_cast to check if the parent is a viewport of
1084  // QAbstractItemView is a crude hack, and should be revisited and
1085  // cleaned up when fixing task 194373. It's here to ensure that we
1086  // keep compatibility outside QAbstractItemView.
1087  d->moveFocus(e->key());
1088  if (hasFocus()) // nothing happend, propagate
1089  e->ignore();
1090  } else {
1091  // Prefer parent widget, use this if parent is absent
1092  QWidget *w = pw ? pw : this;
1093  bool reverse = (w->layoutDirection() == Qt::RightToLeft);
1094  if ((e->key() == Qt::Key_Left && !reverse)
1095  || (e->key() == Qt::Key_Right && reverse)) {
1096  next = false;
1097  }
1099  }
1100  break;
1101  }
1102  default:
1103 #ifndef QT_NO_SHORTCUT
1104  if (e->matches(QKeySequence::Cancel) && d->down) {
1105  setDown(false);
1106  repaint();
1107  d->emitReleased();
1108  return;
1109  }
1110 #endif
1111  e->ignore();
1112  }
1113 }
1114 
1117 {
1118  Q_D(QAbstractButton);
1119 
1120  if (!e->isAutoRepeat())
1121  d->repeatTimer.stop();
1122 
1123  switch (e->key()) {
1124  case Qt::Key_Select:
1125  case Qt::Key_Space:
1126  if (!e->isAutoRepeat() && d->down)
1127  d->click();
1128  break;
1129  default:
1130  e->ignore();
1131  }
1132 }
1133 
1137 {
1138  Q_D(QAbstractButton);
1139  if (e->timerId() == d->repeatTimer.timerId()) {
1140  d->repeatTimer.start(d->autoRepeatInterval, this);
1141  if (d->down) {
1142  QPointer<QAbstractButton> guard(this);
1143  nextCheckState();
1144  if (guard)
1145  d->emitReleased();
1146  if (guard)
1147  d->emitClicked();
1148  if (guard)
1149  d->emitPressed();
1150  }
1151  } else if (e->timerId() == d->animateTimer.timerId()) {
1152  d->animateTimer.stop();
1153  d->click();
1154  }
1155 }
1156 
1159 {
1160  Q_D(QAbstractButton);
1161 #ifdef QT_KEYPAD_NAVIGATION
1162  if (!QApplicationPrivate::keypadNavigationEnabled())
1163 #endif
1164  d->fixFocusPolicy();
1166 }
1167 
1170 {
1171  Q_D(QAbstractButton);
1172  if (e->reason() != Qt::PopupFocusReason && d->down) {
1173  d->down = false;
1174  d->emitReleased();
1175  }
1177 }
1178 
1181 {
1182  Q_D(QAbstractButton);
1183  switch (e->type()) {
1184  case QEvent::EnabledChange:
1185  if (!isEnabled() && d->down) {
1186  d->down = false;
1187  d->emitReleased();
1188  }
1189  break;
1190  default:
1191  d->sizeHint = QSize();
1192  break;
1193  }
1195 }
1196 
1270 {
1271  Q_D(const QAbstractButton);
1272  if (d->iconSize.isValid())
1273  return d->iconSize;
1274  int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, nullptr, this);
1275  return QSize(e, e);
1276 }
1277 
1279 {
1280  Q_D(QAbstractButton);
1281  if (d->iconSize == size)
1282  return;
1283 
1284  d->iconSize = size;
1285  d->sizeHint = QSize();
1286  updateGeometry();
1287  if (isVisible()) {
1288  update();
1289  }
1290 }
1291 
1292 
1293 
1295 
1296 #include "moc_qabstractbutton.cpp"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
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
int autoRepeatDelay
the initial delay of auto-repetition
QIcon icon
the icon shown on the button
void mousePressEvent(QMouseEvent *e) override
void setAutoRepeatDelay(int)
void mouseReleaseEvent(QMouseEvent *e) override
void setAutoExclusive(bool)
bool checkable
whether the button is checkable
void focusInEvent(QFocusEvent *e) override
bool isCheckable() const
void setShortcut(const QKeySequence &key)
void setIcon(const QIcon &icon)
bool event(QEvent *e) override
bool autoRepeat
whether autoRepeat is enabled
void setAutoRepeat(bool)
void setAutoRepeatInterval(int)
int autoRepeatInterval
the interval of auto-repetition
void setCheckable(bool)
bool checked
whether the button is checked
QKeySequence shortcut
the mnemonic associated with the button
bool isDown() const
void timerEvent(QTimerEvent *e) override
bool autoExclusive
whether auto-exclusivity is enabled
QAbstractButton(QWidget *parent=nullptr)
void setIconSize(const QSize &size)
void keyPressEvent(QKeyEvent *e) override
void changeEvent(QEvent *e) override
virtual void checkStateSet()
void setText(const QString &text)
void keyReleaseEvent(QKeyEvent *e) override
bool isChecked() const
QSize iconSize
the icon size used for this button.
void focusOutEvent(QFocusEvent *e) override
virtual bool hitButton(const QPoint &pos) const
virtual void nextCheckState()
QString text
the text shown on the button
QList< QAbstractButton * > queryButtonList() const
QSizePolicy::ControlType controlType
QAbstractButton * queryCheckedButton() const
void emitToggled(bool checked)
QAbstractButtonPrivate(QSizePolicy::ControlType type=QSizePolicy::DefaultType)
The QAccessibleEvent class is the base class for accessibility notifications.
Definition: qaccessible.h:680
static void updateAccessibility(QAccessibleEvent *event)
The QAccessibleStateChangeEvent notfies the accessibility framework that the state of an object has c...
Definition: qaccessible.h:738
static QWidget * focusWidget()
The QButtonGroup class provides a container to organize groups of button widgets.
Definition: qbuttongroup.h:55
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
@ TabletMove
Definition: qcoreevent.h:134
@ EnabledChange
Definition: qcoreevent.h:147
@ Shortcut
Definition: qcoreevent.h:170
@ MouseMove
Definition: qcoreevent.h:76
@ MouseButtonPress
Definition: qcoreevent.h:73
@ HoverLeave
Definition: qcoreevent.h:189
@ HoverEnter
Definition: qcoreevent.h:188
@ TabletRelease
Definition: qcoreevent.h:140
@ HoverMove
Definition: qcoreevent.h:190
@ TabletPress
Definition: qcoreevent.h:139
@ MouseButtonDblClick
Definition: qcoreevent.h:75
@ ContextMenu
Definition: qcoreevent.h:132
@ MouseButtonRelease
Definition: qcoreevent.h:74
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
Definition: qevent.h:520
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:56
The QKeyEvent class describes a key event.
Definition: qevent.h:471
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:71
static QKeySequence mnemonic(const QString &text)
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
qsizetype removeIf(Predicate pred)
Definition: qlist.h:602
qsizetype count() const noexcept
Definition: qlist.h:415
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:231
QObject * parent
Definition: qobject.h:99
QList< T > findChildren(const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Definition: qobject.h:175
@ Button
Definition: qpalette.h:86
@ ButtonText
Definition: qpalette.h:87
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
constexpr int x() const noexcept
Definition: qpoint.h:155
constexpr int y() const noexcept
Definition: qpoint.h:160
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
constexpr int bottom() const noexcept
Definition: qrect.h:209
bool contains(const QRect &r, bool proper=false) const noexcept
Definition: qrect.cpp:887
constexpr int x() const noexcept
Definition: qrect.h:212
constexpr QRect translated(int dx, int dy) const noexcept
Definition: qrect.h:288
constexpr int y() const noexcept
Definition: qrect.h:215
constexpr QPoint center() const noexcept
Definition: qrect.h:260
constexpr int right() const noexcept
Definition: qrect.h:206
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition: qsizepolicy.h:54
The QString class provides a Unicode character string.
Definition: qstring.h:388
@ SH_Button_FocusPolicy
Definition: qstyle.h:668
@ PM_ButtonIconSize
Definition: qstyle.h:541
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:367
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
void setAttribute(Qt::WidgetAttribute, bool on=true)
Definition: qwidget.cpp:11088
void repaint()
Definition: qwidget.cpp:10899
QWidget * window() const
Definition: qwidget.cpp:4319
void releaseShortcut(int id)
Definition: qwidget.cpp:11643
void updateGeometry()
Definition: qwidget.cpp:10386
bool isHidden() const
Definition: qwidget.h:910
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:147
QPointF mapToGlobal(const QPointF &) const
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:145
virtual void focusInEvent(QFocusEvent *event)
Definition: qwidget.cpp:9566
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7773
virtual bool focusNextPrevChild(bool next)
Definition: qwidget.cpp:6759
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:150
void setFocus()
Definition: qwidget.h:454
bool isEnabled() const
Definition: qwidget.h:847
void update()
Definition: qwidget.cpp:10977
virtual void changeEvent(QEvent *)
Definition: qwidget.cpp:9283
bool event(QEvent *event) override
Definition: qwidget.cpp:8772
int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
Definition: qwidget.cpp:11619
QStyle * style() const
Definition: qwidget.cpp:2612
bool hasFocus() const
Definition: qwidget.cpp:6430
virtual void focusOutEvent(QFocusEvent *event)
Definition: qwidget.cpp:9592
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:174
QWidget * parentWidget() const
Definition: qwidget.h:937
bool isVisible() const
Definition: qwidget.h:907
QString text
[meta data]
QPushButton * button
[2]
double e
short next
Definition: keywords.cpp:454
@ NavigationModeKeypadDirectional
Definition: qnamespace.h:1679
@ LeftButton
Definition: qnamespace.h:83
@ WA_KeyboardFocusChange
Definition: qnamespace.h:369
@ WA_WState_OwnSizePolicy
Definition: qnamespace.h:359
@ RightToLeft
Definition: qnamespace.h:1464
FocusPolicy
Definition: qnamespace.h:131
@ ClickFocus
Definition: qnamespace.h:134
@ NoFocus
Definition: qnamespace.h:132
@ TabFocus
Definition: qnamespace.h:133
@ StrongFocus
Definition: qnamespace.h:135
@ Key_Select
Definition: qnamespace.h:1036
@ Key_Return
Definition: qnamespace.h:688
@ Key_Right
Definition: qnamespace.h:700
@ Key_Enter
Definition: qnamespace.h:689
@ Key_Space
Definition: qnamespace.h:538
@ Key_Left
Definition: qnamespace.h:698
@ Key_Up
Definition: qnamespace.h:699
@ Key_Down
Definition: qnamespace.h:701
@ PopupFocusReason
Definition: qnamespace.h:1365
@ BacktabFocusReason
Definition: qnamespace.h:1363
@ TabFocusReason
Definition: qnamespace.h:1362
@ ShortcutFocusReason
Definition: qnamespace.h:1366
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
[3]
#define AUTO_REPEAT_DELAY
Q_WIDGETS_EXPORT bool qt_tab_all_widgets()
#define AUTO_REPEAT_INTERVAL
#define Q_FALLTHROUGH()
unsigned int uint
Definition: qglobal.h:334
#define QT_CONFIG(feature)
Definition: qglobal.h:107
GLenum type
Definition: qopengl.h:270
GLboolean GLboolean GLboolean b
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat f
GLboolean GLuint group
GLenum target
struct _cl_event * event
Definition: qopenglext.h:2998
GLdouble GLdouble GLdouble GLdouble q
Definition: qopenglext.h:259
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
QPointF qAbs(const QPointF &p)
Definition: qscroller.cpp:119
#define emit
Definition: qtmetamacros.h:85
QIcon icon
[15]
QObject::connect nullptr
bool contains(const AT &t) const noexcept
Definition: qlist.h:78
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent