Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmenubar.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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 <qmenubar.h>
5
6#include <qstyle.h>
7#include <qlayout.h>
8#include <qapplication.h>
9#if QT_CONFIG(accessibility)
10# include <qaccessible.h>
11#endif
12#include <qpainter.h>
13#include <qstylepainter.h>
14#include <qevent.h>
15#if QT_CONFIG(mainwindow)
16#include <qmainwindow.h>
17#endif
18#if QT_CONFIG(toolbar)
19#include <qtoolbar.h>
20#endif
21#if QT_CONFIG(toolbutton)
22#include <qtoolbutton.h>
23#endif
24#if QT_CONFIG(whatsthis)
25#include <qwhatsthis.h>
26#endif
27#include <qpa/qplatformtheme.h>
28#include "private/qguiapplication_p.h"
29#include "qpa/qplatformintegration.h"
30
31#include "qmenu_p.h"
32#include "qmenubar_p.h"
33#include <private/qscreen_p.h>
34#include "qdebug.h"
35
37
38using namespace Qt::StringLiterals;
39
41{
42public:
44
45 QSize sizeHint() const override;
46 void paintEvent(QPaintEvent *) override;
47};
48
50 : QToolButton(parent)
51{
52 setObjectName("qt_menubar_ext_button"_L1);
53 setAutoRaise(true);
54#if QT_CONFIG(menu)
55 setPopupMode(QToolButton::InstantPopup);
56#endif
58}
59
61{
62 QStylePainter p(this);
65 // We do not need to draw both extension arrows
67 p.drawComplexControl(QStyle::CC_ToolButton, opt);
68}
69
70
72{
74 return QSize(ext, ext);
75}
76
77
82{
83 for(int i = 0; i < actions.size(); ++i) {
85 return actions.at(i);
86 }
87 return nullptr;
88}
89
90QRect QMenuBarPrivate::menuRect(bool extVisible) const
91{
92 Q_Q(const QMenuBar);
93
94 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
95 QRect result = q->rect();
96 result.adjust(hmargin, 0, -hmargin, 0);
97
98 if (extVisible) {
99 if (q->isRightToLeft())
100 result.setLeft(result.left() + extension->sizeHint().width());
101 else
102 result.setWidth(result.width() - extension->sizeHint().width());
103 }
104
105 if (leftWidget && leftWidget->isVisible()) {
106 QSize sz = leftWidget->sizeHint();
107 if (q->isRightToLeft())
108 result.setRight(result.right() - sz.width());
109 else
110 result.setLeft(result.left() + sz.width());
111 }
112
114 QSize sz = rightWidget->sizeHint();
115 if (q->isRightToLeft())
116 result.setLeft(result.left() + sz.width());
117 else
118 result.setRight(result.right() - sz.width());
119 }
120
121 return result;
122}
123
125{
126 return !hiddenActions.contains(action);
127}
128
130{
131 Q_Q(QMenuBar);
132 if (!itemsDirty)
133 return;
134 int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q)*2);
135 int q_start = -1;
136 if (leftWidget || rightWidget) {
137 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q)
138 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
139 int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q)
140 + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
141 if (leftWidget && leftWidget->isVisible()) {
142 QSize sz = leftWidget->sizeHint();
143 q_width -= sz.width();
144 q_start = sz.width();
145 QPoint pos(hmargin, (q->height() - leftWidget->height()) / 2);
146 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
147 leftWidget->setGeometry(vRect);
148 }
150 QSize sz = rightWidget->sizeHint();
151 q_width -= sz.width();
152 QPoint pos(q->width() - sz.width() - hmargin, vmargin);
153 QRect vRect = QStyle::visualRect(q->layoutDirection(), q->rect(), QRect(pos, sz));
154 rightWidget->setGeometry(vRect);
155 }
156 }
157
158#ifdef Q_OS_MAC
159 if (q->isNativeMenuBar()) {//nothing to see here folks, move along..
160 itemsDirty = false;
161 return;
162 }
163#endif
164 calcActionRects(q_width, q_start);
165 currentAction = nullptr;
166#ifndef QT_NO_SHORTCUT
167 if (itemsDirty) {
168 for(int j = 0; j < shortcutIndexMap.size(); ++j)
169 q->releaseShortcut(shortcutIndexMap.value(j));
171 const int actionsCount = actions.size();
172 shortcutIndexMap.reserve(actionsCount);
173 for (int i = 0; i < actionsCount; i++)
175 }
176#endif
177 itemsDirty = false;
178
180 //this is the menu rectangle without any extension
181 QRect menuRect = this->menuRect(false);
182
183 //we try to see if the actions will fit there
184 bool hasHiddenActions = false;
185 for (int i = 0; i < actions.size(); ++i) {
186 const QRect &rect = actionRects.at(i);
187 if (rect.isValid() && !menuRect.contains(rect)) {
188 hasHiddenActions = true;
189 break;
190 }
191 }
192
193 //...and if not, determine the ones that fit on the menu with the extension visible
194 if (hasHiddenActions) {
195 menuRect = this->menuRect(true);
196 for (int i = 0; i < actions.size(); ++i) {
197 const QRect &rect = actionRects.at(i);
198 if (rect.isValid() && !menuRect.contains(rect)) {
200 }
201 }
202 }
203
204 if (hiddenActions.size() > 0) {
205 QMenu *pop = extension->menu();
206 if (!pop) {
207 pop = new QMenu(q);
208 extension->setMenu(pop);
209 }
210 pop->clear();
212
213 int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q);
214 int x = q->isRightToLeft()
215 ? menuRect.left() - extension->sizeHint().width() + 1
216 : menuRect.right();
217 extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2);
218 extension->show();
219 } else {
220 extension->hide();
221 }
222 q->updateGeometry();
223}
224
226{
227 const int index = actions.indexOf(act);
228
229 //makes sure the geometries are up-to-date
230 const_cast<QMenuBarPrivate*>(this)->updateGeometries();
231
232 if (index < 0 || index >= actionRects.size())
233 return QRect(); // that can happen in case of native menubar
234
235 return actionRects.at(index);
236}
237
239{
240 if (!currentAction) {
242 int index = 0;
243 while (index < actions.size() && actionRects.at(index).isNull()) ++index;
244 if (index < actions.size())
246 }
247}
248
250{
251 Q_Q(QMenuBar);
252 if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) {
253 setCurrentAction(nullptr);
254 return;
255 }
257 if (b) {
259 if (fw && fw != q && fw->window() != QApplication::activePopupWidget())
262 q->setFocus(Qt::MenuBarFocusReason);
263 } else {
264 if (!popupState)
265 setCurrentAction(nullptr);
269 keyboardFocusWidget = nullptr;
270 }
271 }
272 q->update();
273}
274
275void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
276{
277 Q_Q(QMenuBar);
278 if (!action || !action->menu() || closePopupMode)
279 return;
280 popupState = true;
281 if (action->isEnabled() && action->menu()->isEnabled()) {
282 closePopupMode = 0;
283 activeMenu = action->menu();
284 auto *activeMenuPriv = activeMenu->d_func();
285 activeMenuPriv->causedPopup.widget = q;
286 activeMenuPriv->causedPopup.action = action;
287
288 QRect adjustedActionRect = actionRect(action);
289 QPoint popupPos = adjustedActionRect.bottomLeft() + QPoint(0, 1);
290
291 //we put the popup menu on the screen containing the bottom-center of the action rect
292 QScreen *menubarScreen = q->window()->windowHandle()->screen();
293 QPoint screenTestPos = q->mapToGlobal(popupPos + QPoint(adjustedActionRect.width() / 2, 0));
294 QPointer<QScreen> popupScreen = menubarScreen->virtualSiblingAt(screenTestPos);
295 if (!popupScreen)
296 popupScreen = menubarScreen;
297 std::swap(popupScreen, activeMenuPriv->popupScreen);
298 const QSize popup_size = activeMenu->sizeHint();
299 std::swap(popupScreen, activeMenuPriv->popupScreen);
300
301 // Use screenTestPos.y() for the popup y position. This is the correct global y
302 // consistent with the selected screen in cases where the action rect spans
303 // multiple screens with different scale factors.
304 QPoint pos(q->mapToGlobal(popupPos).x(), screenTestPos.y());
305
306 QRect screenRect = popupScreen->geometry();
307 pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
308 const bool fitUp = (pos.y() - popup_size.height() >= screenRect.top());
309 const bool fitDown = (pos.y() + popup_size.height() <= screenRect.bottom());
310 const bool rtl = q->isRightToLeft();
311 const int actionWidth = adjustedActionRect.width();
312
313 if (!fitUp && !fitDown) { //we should shift the menu
314 bool shouldShiftToRight = !rtl;
315 if (rtl && popup_size.width() > pos.x())
316 shouldShiftToRight = true;
317 else if (actionWidth + popup_size.width() + pos.x() > screenRect.right())
318 shouldShiftToRight = false;
319
320 if (shouldShiftToRight) {
321 pos.rx() += actionWidth + (rtl ? popup_size.width() : 0);
322 } else {
323 //shift to left
324 if (!rtl)
325 pos.rx() -= popup_size.width();
326 }
327 } else if (rtl) {
328 pos.rx() += actionWidth;
329 }
330
331 if (!defaultPopDown || (fitUp && !fitDown))
332 pos.setY(qMax(screenRect.y(), q->mapToGlobal(QPoint(0, adjustedActionRect.top()-popup_size.height())).y()));
333 QMenuPrivate::get(activeMenu)->topData()->initialScreen = popupScreen;
335 if (activateFirst)
336 activeMenu->d_func()->setFirstActionActive();
337 }
338 q->update(actionRect(action));
339}
340
341void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activateFirst)
342{
343 if (currentAction == action && popup == popupState)
344 return;
345
347
348 doChildEffects = (popup && !activeMenu);
349 Q_Q(QMenuBar);
350 QWidget *fw = nullptr;
351 if (QMenu *menu = activeMenu) {
352 activeMenu = nullptr;
353 if (popup) {
354 fw = q->window()->focusWidget();
356 }
357 menu->hide();
358 }
359
360 if (currentAction)
361 q->update(actionRect(currentAction));
362
363 popupState = popup;
364#if QT_CONFIG(statustip)
365 QAction *previousAction = currentAction;
366#endif
367 currentAction = action;
368 if (action && action->isEnabled()) {
370 if (popup)
371 popupAction(action, activateFirst);
372 q->update(actionRect(action));
373#if QT_CONFIG(statustip)
374 } else if (previousAction) {
375 QString empty;
376 QStatusTipEvent tip(empty);
378#endif
379 }
380 if (fw)
382}
383
384void QMenuBarPrivate::calcActionRects(int max_width, int start) const
385{
386 Q_Q(const QMenuBar);
387
388 if (!itemsDirty)
389 return;
390
391 //let's reinitialize the buffer
394
395 const QStyle *style = q->style();
396
397 const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, nullptr, q);
398 int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
399
400 //calculate size
401 const QFontMetrics fm = q->fontMetrics();
402 const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q),
403 vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q),
404 icone = style->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q);
405 for(int i = 0; i < actions.size(); i++) {
406 QAction *action = actions.at(i);
407 if (!action->isVisible())
408 continue;
409
410 QSize sz;
411
412 //calc what I think the size is..
413 if (action->isSeparator()) {
414 if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, nullptr, q))
415 separator = i;
416 continue; //we don't really position these!
417 } else {
418 const QString s = action->text();
419 QIcon is = action->icon();
420 // If an icon is set, only the icon is visible
421 if (!is.isNull())
422 sz = sz.expandedTo(QSize(icone, icone));
423 else if (!s.isEmpty())
424 sz = fm.size(Qt::TextShowMnemonic, s);
425 }
426
427 //let the style modify the above size..
429 q->initStyleOption(&opt, action);
430 sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
431
432 if (!sz.isEmpty()) {
433 { //update the separator state
434 int iWidth = sz.width() + itemSpacing;
435 if (separator == -1)
436 separator_start += iWidth;
437 else
438 separator_len += iWidth;
439 }
440 //maximum height
441 max_item_height = qMax(max_item_height, sz.height());
442 //append
443 actionRects[i] = QRect(0, 0, sz.width(), sz.height());
444 }
445 }
446
447 //calculate position
448 const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
449 int x = fw + ((start == -1) ? hmargin : start) + itemSpacing;
450 int y = fw + vmargin;
451 for(int i = 0; i < actions.size(); i++) {
453 if (rect.isNull())
454 continue;
455
456 //resize
457 rect.setHeight(max_item_height);
458
459 //move
460 if (separator != -1 && i >= separator) { //after the separator
461 int left = (max_width - separator_len - hmargin - itemSpacing) + (x - separator_start - hmargin);
462 if (left < separator_start) { //wrap
463 separator_start = x = hmargin;
464 y += max_item_height;
465 }
466 rect.moveLeft(left);
467 } else {
468 rect.moveLeft(x);
469 }
470 rect.moveTop(y);
471
472 //keep moving along..
473 x += rect.width() + itemSpacing;
474
475 //make sure we follow the layout direction
476 rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect);
477 }
478}
479
481{
482 Q_Q(QMenuBar);
483 if (!action || !action->isEnabled())
484 return;
485 action->activate(action_e);
486 if (action_e == QAction::Hover)
487 action->showStatusText(q);
488
489// if (action_e == QAction::Trigger)
490// emit q->activated(action);
491// else if (action_e == QAction::Hover)
492// emit q->highlighted(action);
493}
494
495
497{
498 Q_Q(QMenuBar);
499 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
500 emit q->triggered(action);
501 }
502}
503
505{
506 Q_Q(QMenuBar);
507 if (QAction *action = qobject_cast<QAction *>(q->sender())) {
508 emit q->hovered(action);
509#if QT_CONFIG(accessibility)
510 if (QAccessible::isActive()) {
511 int actionIndex = actions.indexOf(action);
512 QAccessibleEvent focusEvent(q, QAccessible::Focus);
513 focusEvent.setChild(actionIndex);
514 QAccessible::updateAccessibility(&focusEvent);
515 }
516#endif // QT_CONFIG(accessibility)
517 }
518}
519
528{
529 if (!option || !action)
530 return;
531 Q_D(const QMenuBar);
532 option->palette = palette();
533 option->state = QStyle::State_None;
534 if (isEnabled() && action->isEnabled())
536 else
537 option->palette.setCurrentColorGroup(QPalette::Disabled);
538 option->fontMetrics = fontMetrics();
539 if (d->currentAction && d->currentAction == action) {
541 if (d->popupState && !d->closePopupMode)
543 }
544 if (hasFocus() || d->currentAction)
546 option->menuRect = rect();
547 option->menuItemType = QStyleOptionMenuItem::Normal;
549 option->text = action->text();
550 option->icon = action->icon();
551}
552
671{
672 Q_Q(QMenuBar);
674 q->setAttribute(Qt::WA_CustomWhatsThis);
675
677 platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
678
679 if (platformMenuBar)
680 q->hide();
681 q->setBackgroundRole(QPalette::Button);
683 q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, q));
684
687 extension->hide();
688}
689
690//Gets the next action for keyboard navigation
691QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) const
692{
693 Q_Q(const QMenuBar);
694 const_cast<QMenuBarPrivate*>(this)->updateGeometries();
695 bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q);
696 const int start = (_start == -1 && increment == -1) ? actions.size() : _start;
697 const int end = increment == -1 ? 0 : actions.size() - 1;
698
699 for (int i = start; i != end;) {
700 i += increment;
701 QAction *current = actions.at(i);
702 if (!actionRects.at(i).isNull() && (allowActiveAndDisabled || current->isEnabled()))
703 return current;
704 }
705
706 if (_start != -1) //let's try from the beginning or the end
707 return getNextAction(-1, increment);
708
709 return nullptr;
710}
711
716{
717 Q_D(QMenuBar);
718 d->init();
719}
720
721
726{
727 Q_D(QMenuBar);
728 delete d->platformMenuBar;
729 d->platformMenuBar = nullptr;
730}
731
739{
740 QMenu *menu = new QMenu(title, this);
742 return menu;
743}
744
752{
753 QMenu *menu = new QMenu(title, this);
754 menu->setIcon(icon);
756 return menu;
757}
758
769{
770 QAction *action = menu->menuAction();
771 addAction(action);
772 return action;
773}
774
779{
780 QAction *ret = new QAction(this);
781 ret->setSeparator(true);
782 addAction(ret);
783 return ret;
784}
785
795{
796 QAction *action = new QAction(this);
797 action->setSeparator(true);
798 insertAction(before, action);
799 return action;
800}
801
809{
810 QAction *action = menu->menuAction();
811 insertAction(before, action);
812 return action;
813}
814
820{
821 Q_D(const QMenuBar);
822 return d->currentAction;
823}
824
831{
832 Q_D(QMenuBar);
833 d->setCurrentAction(act, true, false);
834}
835
836
850{
851 QList<QAction*> acts = actions();
852 for(int i = 0; i < acts.size(); i++)
853 removeAction(acts[i]);
854}
855
869{
870 Q_D(QMenuBar);
871 d->defaultPopDown = !b;
872}
873
875{
876 Q_D(const QMenuBar);
877 return !d->defaultPopDown;
878}
879
884{
885 Q_D(QMenuBar);
886 d->itemsDirty = true;
887 d->updateGeometries();
888}
889
894{
895 Q_D(QMenuBar);
896 QPainter p(this);
897 QRegion emptyArea(rect());
898
899 //draw the items
900 for (int i = 0; i < d->actions.size(); ++i) {
901 QAction *action = d->actions.at(i);
902 QRect adjustedActionRect = d->actionRect(action);
903 if (adjustedActionRect.isEmpty() || !d->isVisible(action))
904 continue;
905 if (!e->rect().intersects(adjustedActionRect))
906 continue;
907
908 emptyArea -= adjustedActionRect;
910 initStyleOption(&opt, action);
911 opt.rect = adjustedActionRect;
912 p.setClipRect(adjustedActionRect);
914 }
915 //draw border
916 if (int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this)) {
917 QRegion borderReg;
918 borderReg += QRect(0, 0, fw, height()); //left
919 borderReg += QRect(width()-fw, 0, fw, height()); //right
920 borderReg += QRect(0, 0, width(), fw); //top
921 borderReg += QRect(0, height()-fw, width(), fw); //bottom
922 p.setClipRegion(borderReg);
923 emptyArea -= borderReg;
925 frame.rect = rect();
931 }
932 p.setClipRegion(emptyArea);
933 QStyleOptionMenuItem menuOpt;
934 menuOpt.palette = palette();
935 menuOpt.state = QStyle::State_None;
936 menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea;
937 menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
938 menuOpt.rect = rect();
939 menuOpt.menuRect = rect();
940 style()->drawControl(QStyle::CE_MenuBarEmptyArea, &menuOpt, &p, this);
941}
942
946void QMenuBar::setVisible(bool visible)
947{
948 if (isNativeMenuBar()) {
949 if (!visible)
950 QWidget::setVisible(false);
951 return;
952 }
954}
955
960{
961 Q_D(QMenuBar);
962 if (e->button() != Qt::LeftButton)
963 return;
964
965 d->mouseDown = true;
966
967 QAction *action = d->actionAt(e->position().toPoint());
968 if (!action || !d->isVisible(action) || !action->isEnabled()) {
969 d->setCurrentAction(nullptr);
970#if QT_CONFIG(whatsthis)
972 QWhatsThis::showText(e->globalPosition().toPoint(), d->whatsThis, this);
973#endif
974 return;
975 }
976
977 if (d->currentAction == action && d->popupState) {
978 if (QMenu *menu = d->activeMenu) {
979 d->activeMenu = nullptr;
981 menu->hide();
982 }
983 } else {
984 d->setCurrentAction(action, true);
985 }
986}
987
992{
993 Q_D(QMenuBar);
994 if (e->button() != Qt::LeftButton || !d->mouseDown)
995 return;
996
997 d->mouseDown = false;
998 QAction *action = d->actionAt(e->position().toPoint());
999
1000 // do noting if the action is hidden
1001 if (!d->isVisible(action))
1002 return;
1003 if ((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
1004 //we set the current action before activating
1005 //so that we let the leave event set the current back to 0
1006 d->setCurrentAction(action, false);
1007 if (action)
1008 d->activateAction(action, QAction::Trigger);
1009 }
1010 d->closePopupMode = 0;
1011}
1012
1017{
1018 Q_D(QMenuBar);
1019 d->updateGeometries();
1020 int key = e->key();
1021 if (isRightToLeft()) { // in reverse mode open/close key for submenues are reversed
1022 if (key == Qt::Key_Left)
1024 else if (key == Qt::Key_Right)
1025 key = Qt::Key_Left;
1026 }
1027 if (key == Qt::Key_Tab) //means right
1029 else if (key == Qt::Key_Backtab) //means left
1030 key = Qt::Key_Left;
1031
1032 bool key_consumed = false;
1033 switch(key) {
1034 case Qt::Key_Up:
1035 case Qt::Key_Down:
1036 case Qt::Key_Enter:
1037 case Qt::Key_Space:
1038 case Qt::Key_Return: {
1039 if (!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this) || !d->currentAction)
1040 break;
1041 if (d->currentAction->menu()) {
1042 d->popupAction(d->currentAction, true);
1043 } else if (key == Qt::Key_Enter || key == Qt::Key_Return || key == Qt::Key_Space) {
1044 d->activateAction(d->currentAction, QAction::Trigger);
1045 d->setCurrentAction(d->currentAction, false);
1046 d->setKeyboardMode(false);
1047 }
1048 key_consumed = true;
1049 break; }
1050
1051 case Qt::Key_Right:
1052 case Qt::Key_Left: {
1053 if (d->currentAction) {
1054 int index = d->actions.indexOf(d->currentAction);
1055 if (QAction *nextAction = d->getNextAction(index, key == Qt::Key_Left ? -1 : +1)) {
1056 d->setCurrentAction(nextAction, d->popupState, true);
1057 key_consumed = true;
1058 }
1059 }
1060 break; }
1061
1062 default:
1063 key_consumed = false;
1064 }
1065
1066#ifndef QT_NO_SHORTCUT
1067 if (!key_consumed && e->matches(QKeySequence::Cancel)) {
1068 d->setCurrentAction(nullptr);
1069 d->setKeyboardMode(false);
1070 key_consumed = true;
1071 }
1072#endif
1073
1074 if (!key_consumed &&
1075 (!e->modifiers() ||
1076 (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().size()==1 && !d->popupState) {
1077 int clashCount = 0;
1078 QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr;
1079 {
1080 const QChar c = e->text().at(0).toUpper();
1081 for(int i = 0; i < d->actions.size(); ++i) {
1082 if (d->actionRects.at(i).isNull())
1083 continue;
1084 QAction *act = d->actions.at(i);
1085 QString s = act->text();
1086 if (!s.isEmpty()) {
1087 qsizetype ampersand = s.indexOf(u'&');
1088 if (ampersand >= 0) {
1089 if (s[ampersand+1].toUpper() == c) {
1090 clashCount++;
1091 if (!first)
1092 first = act;
1093 if (act == d->currentAction)
1094 currentSelected = act;
1095 else if (!firstAfterCurrent && currentSelected)
1096 firstAfterCurrent = act;
1097 }
1098 }
1099 }
1100 }
1101 }
1102 QAction *next_action = nullptr;
1103 if (clashCount >= 1) {
1104 if (clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent))
1105 next_action = first;
1106 else
1107 next_action = firstAfterCurrent;
1108 }
1109 if (next_action) {
1110 key_consumed = true;
1111 d->setCurrentAction(next_action, true, true);
1112 }
1113 }
1114 if (key_consumed)
1115 e->accept();
1116 else
1117 e->ignore();
1118}
1119
1124{
1125 Q_D(QMenuBar);
1126 if (!(e->buttons() & Qt::LeftButton)) {
1127 d->mouseDown = false;
1128 // We receive mouse move and mouse press on touch.
1129 // Mouse move will open the menu and mouse press
1130 // will close it, so ignore mouse move.
1132 return;
1133 }
1134
1135 bool popupState = d->popupState || d->mouseDown;
1136 QAction *action = d->actionAt(e->position().toPoint());
1137 if ((action && d->isVisible(action)) || !popupState)
1138 d->setCurrentAction(action, popupState);
1139}
1140
1145{
1146 Q_D(QMenuBar);
1147 if ((!hasFocus() && !d->popupState) ||
1148 (d->currentAction && d->currentAction->menu() == nullptr))
1149 d->setCurrentAction(nullptr);
1150}
1151
1153{
1154 if (!action || !action->menu())
1155 return nullptr;
1156
1157 QPlatformMenu *platformMenu = action->menu()->platformMenu();
1158 if (!platformMenu && platformMenuBar) {
1160 if (platformMenu)
1161 action->menu()->setPlatformMenu(platformMenu);
1162 }
1163
1164 return platformMenu;
1165}
1166
1168{
1169 Q_Q(QMenuBar);
1170 QPlatformMenu *beforeMenu = nullptr;
1171 for (int beforeIndex = indexOf(const_cast<QAction *>(action)) + 1;
1172 !beforeMenu && (beforeIndex < q->actions().size());
1173 ++beforeIndex) {
1174 beforeMenu = getPlatformMenu(q->actions().at(beforeIndex));
1175 }
1176
1177 return beforeMenu;
1178}
1179
1181{
1182 const auto tag = reinterpret_cast<quintptr>(action);
1183 if (menu->tag() != tag)
1184 menu->setTag(tag);
1185 menu->setText(action->text());
1186 menu->setVisible(action->isVisible());
1187 menu->setEnabled(action->isEnabled());
1188}
1189
1194{
1195 Q_D(QMenuBar);
1196 d->itemsDirty = true;
1197
1198 if (d->platformMenuBar) {
1199 QPlatformMenuBar *nativeMenuBar = d->platformMenuBar;
1200 if (!nativeMenuBar)
1201 return;
1202
1203 auto action = static_cast<QAction *>(e->action());
1204 if (e->type() == QEvent::ActionAdded) {
1205 QPlatformMenu *menu = d->getPlatformMenu(action);
1206 if (menu) {
1207 d->copyActionToPlatformMenu(action, menu);
1208
1209 QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(action);
1210 d->platformMenuBar->insertMenu(menu, beforeMenu);
1211 }
1212 } else if (e->type() == QEvent::ActionRemoved) {
1213 QPlatformMenu *menu = d->getPlatformMenu(action);
1214 if (menu)
1215 d->platformMenuBar->removeMenu(menu);
1216 } else if (e->type() == QEvent::ActionChanged) {
1217 QPlatformMenu *cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));
1218 QPlatformMenu *menu = d->getPlatformMenu(action);
1219
1220 // the menu associated with the action can change, need to
1221 // remove and/or insert the new platform menu
1222 if (menu != cur) {
1223 if (cur)
1224 d->platformMenuBar->removeMenu(cur);
1225 if (menu) {
1226 d->copyActionToPlatformMenu(action, menu);
1227
1228 QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(action);
1229 d->platformMenuBar->insertMenu(menu, beforeMenu);
1230 }
1231 } else if (menu) {
1232 d->copyActionToPlatformMenu(action, menu);
1233 d->platformMenuBar->syncMenu(menu);
1234 }
1235 }
1236 }
1237
1238 if (e->type() == QEvent::ActionAdded) {
1239 connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
1240 connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
1241 } else if (e->type() == QEvent::ActionRemoved) {
1242 e->action()->disconnect(this);
1243 }
1244 // updateGeometries() is also needed for native menu bars because
1245 // it updates shortcutIndexMap
1246 if (isVisible() || isNativeMenuBar())
1247 d->updateGeometries();
1248 if (isVisible())
1249 update();
1250}
1251
1256{
1257 Q_D(QMenuBar);
1258 if (d->keyboardState)
1259 d->focusFirstAction();
1260}
1261
1266{
1267 Q_D(QMenuBar);
1268 if (!d->popupState) {
1269 d->setCurrentAction(nullptr);
1270 d->setKeyboardMode(false);
1271 }
1272}
1273
1278{
1279 Q_D(QMenuBar);
1280 if (e->timerId() == d->autoReleaseTimer.timerId()) {
1281 d->autoReleaseTimer.stop();
1282 d->setCurrentAction(nullptr);
1283 }
1285}
1286
1287
1289{
1290 Q_Q(QMenuBar);
1291 QWidget *newParent = q->parentWidget();
1292
1293 //Note: if parent is reparented, then window may change even if parent doesn't.
1294 // We need to install an avent filter on each parent up to the parent that is
1295 // also a window (for shortcuts)
1296 QWidget *newWindow = newParent ? newParent->window() : nullptr;
1297
1298 QList<QPointer<QWidget>> newParents;
1299 // Remove event filters on ex-parents, keep them on still-parents
1300 // The parents are always ordered in the vector
1301 //
1302 // Take a copy because this method is called from changeEvent() and eventFilter(),
1303 // which might cause recursion into the class due to event processing, which might
1304 // modify oldParents.
1305 const auto copy = oldParents;
1306 for (const QPointer<QWidget> &w : copy) {
1307 if (w) {
1308 if (newParent == w) {
1309 newParents.append(w);
1310 if (newParent != newWindow) //stop at the window
1311 newParent = newParent->parentWidget();
1312 } else {
1314 }
1315 }
1316 }
1317
1318 // At this point, newParent is the next one to be added to newParents
1319 while (newParent && newParent != newWindow) {
1320 //install event filters all the way up to (excluding) the window
1321 newParents.append(newParent);
1322 newParent->installEventFilter(q);
1323 newParent = newParent->parentWidget();
1324 }
1325
1326 if (newParent && newWindow) {
1327 // Install the event filter on the window
1328 newParents.append(newParent);
1329 newParent->installEventFilter(q);
1330 }
1331 oldParents = newParents;
1332
1333 if (platformMenuBar) {
1334 if (newWindow) {
1335 // force the underlying platform window to be created, since
1336 // the platform menubar needs it (and we have no other way to
1337 // discover when the platform window is created)
1338 newWindow->createWinId();
1339 platformMenuBar->handleReparent(newWindow->windowHandle());
1340 } else {
1342 }
1343 }
1344}
1345
1350{
1351 Q_D(QMenuBar);
1352 if (e->type() == QEvent::StyleChange) {
1353 d->itemsDirty = true;
1354 setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, this));
1355 if (parentWidget())
1357 d->updateGeometries();
1358 } else if (e->type() == QEvent::ParentChange) {
1359 d->handleReparent();
1360 } else if (e->type() == QEvent::FontChange
1362 d->itemsDirty = true;
1363 d->updateGeometries();
1364 }
1365
1367}
1368
1373{
1374 Q_D(QMenuBar);
1375 switch (e->type()) {
1376 case QEvent::KeyPress: {
1377 QKeyEvent *ke = static_cast<QKeyEvent *>(e);
1378#if 0
1379 if (!d->keyboardState) { //all keypresses..
1380 d->setCurrentAction(0);
1381 return ;
1382 }
1383#endif
1384 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
1385 keyPressEvent(ke);
1386 return true;
1387 }
1388
1389 } break;
1390#ifndef QT_NO_SHORTCUT
1391 case QEvent::Shortcut: {
1392 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
1393 int shortcutId = se->shortcutId();
1394 for(int j = 0; j < d->shortcutIndexMap.size(); ++j) {
1395 if (shortcutId == d->shortcutIndexMap.value(j))
1396 d->_q_internalShortcutActivated(j);
1397 }
1398 } break;
1399#endif
1400 case QEvent::Show:
1401 d->_q_updateLayout();
1402 break;
1403#ifndef QT_NO_SHORTCUT
1405 QKeyEvent *kev = static_cast<QKeyEvent *>(e);
1406 //we only filter out escape if there is a current action
1407 if (kev->matches(QKeySequence::Cancel) && d->currentAction) {
1408 e->accept();
1409 return true;
1410 }
1411 }
1412 break;
1413#endif
1414#if QT_CONFIG(whatsthis)
1416 e->setAccepted(d->whatsThis.size());
1417 if (QAction *action = d->actionAt(static_cast<QHelpEvent*>(e)->pos())) {
1418 if (action->whatsThis().size() || action->menu())
1419 e->accept();
1420 }
1421 return true;
1422#endif
1424 d->_q_updateLayout();
1425 break;
1426 default:
1427 break;
1428 }
1429 return QWidget::event(e);
1430}
1431
1436{
1437 Q_D(QMenuBar);
1438 if (object && (event->type() == QEvent::ParentChange)) //GrandparentChange
1439 d->handleReparent();
1440
1441 if (object == d->leftWidget || object == d->rightWidget) {
1442 switch (event->type()) {
1445 d->_q_updateLayout();
1446 break;
1447 default:
1448 break;
1449 }
1450 }
1451
1452 if (isNativeMenuBar() && event->type() == QEvent::ShowToParent) {
1453 // On some desktops like Unity, the D-Bus menu bar is unregistered
1454 // when the window is hidden. So when the window is shown, we need
1455 // to forcefully re-register it. The only way to force re-registering
1456 // with D-Bus menu is the handleReparent method.
1458 QWindow *handle = widget ? widget->windowHandle() : nullptr;
1459 if (handle != nullptr)
1460 d->platformMenuBar->handleReparent(handle);
1461 }
1462
1463 if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this)) {
1464 if (d->altPressed) {
1465 switch (event->type()) {
1466 case QEvent::KeyPress:
1467 case QEvent::KeyRelease:
1468 {
1469 QKeyEvent *kev = static_cast<QKeyEvent*>(event);
1470 if (kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta) {
1471 if (event->type() == QEvent::KeyPress) // Alt-press does not interest us, we have the shortcut-override event
1472 break;
1473 d->setKeyboardMode(!d->keyboardState);
1474 }
1475 }
1476 Q_FALLTHROUGH();
1479 case QEvent::MouseMove:
1480 case QEvent::FocusIn:
1481 case QEvent::FocusOut:
1483 case QEvent::Shortcut:
1484 d->altPressed = false;
1485 qApp->removeEventFilter(this);
1486 break;
1487 default:
1488 break;
1489 }
1490 } else if (isVisible()) {
1491 if (event->type() == QEvent::ShortcutOverride) {
1492 QKeyEvent *kev = static_cast<QKeyEvent*>(event);
1493 if ((kev->key() == Qt::Key_Alt || kev->key() == Qt::Key_Meta)
1494 && kev->modifiers() == Qt::AltModifier) {
1495 d->altPressed = true;
1496 qApp->installEventFilter(this);
1497 }
1498 }
1499 }
1500 }
1501
1502 return false;
1503}
1504
1512{
1513 Q_D(const QMenuBar);
1514 return d->actionAt(pt);
1515}
1516
1523{
1524 Q_D(const QMenuBar);
1525 return d->actionRect(act);
1526}
1527
1532{
1533 Q_D(const QMenuBar);
1534 const bool as_gui_menubar = !isNativeMenuBar();
1535
1537 QSize ret(0, 0);
1538 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
1539 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this);
1540 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
1541 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
1542 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
1543 if (as_gui_menubar) {
1545 d->calcActionRects(w - (2 * fw), 0);
1546 for (int i = 0; ret.isNull() && i < d->actions.size(); ++i)
1547 ret = d->actionRects.at(i).size();
1548 if (!d->extension->isHidden())
1549 ret += QSize(d->extension->sizeHint().width(), 0);
1550 ret += QSize(2*fw + hmargin, 2*fw + vmargin);
1551 }
1552 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
1553 if (d->leftWidget) {
1554 QSize sz = d->leftWidget->minimumSizeHint();
1555 ret.setWidth(ret.width() + sz.width());
1556 if (sz.height() + margin > ret.height())
1557 ret.setHeight(sz.height() + margin);
1558 }
1559 if (d->rightWidget) {
1560 QSize sz = d->rightWidget->minimumSizeHint();
1561 ret.setWidth(ret.width() + sz.width());
1562 if (sz.height() + margin > ret.height())
1563 ret.setHeight(sz.height() + margin);
1564 }
1565 if (as_gui_menubar) {
1567 opt.rect = rect();
1568 opt.menuRect = rect();
1570 opt.menuItemType = QStyleOptionMenuItem::Normal;
1572 opt.palette = palette();
1573 return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret, this);
1574 }
1575 return ret;
1576}
1577
1582{
1583 Q_D(const QMenuBar);
1584 const bool as_gui_menubar = !isNativeMenuBar();
1585
1587 QSize ret(0, 0);
1588 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
1589 const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this);
1590 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
1591 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
1592 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
1593 if (as_gui_menubar) {
1595 d->calcActionRects(w - (2 * fw), 0);
1596 for (int i = 0; i < d->actionRects.size(); ++i) {
1597 const QRect &actionRect = d->actionRects.at(i);
1598 ret = ret.expandedTo(QSize(actionRect.x() + actionRect.width(), actionRect.y() + actionRect.height()));
1599 }
1600 //the action geometries already contain the top and left
1601 //margins. So we only need to add those from right and bottom.
1602 ret += QSize(fw + hmargin, fw + vmargin);
1603 }
1604 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
1605 if (d->leftWidget) {
1606 QSize sz = d->leftWidget->sizeHint();
1607 sz.rheight() += margin;
1608 ret = ret.expandedTo(sz);
1609 }
1610 if (d->rightWidget) {
1611 QSize sz = d->rightWidget->sizeHint();
1612 ret.setWidth(ret.width() + sz.width());
1613 if (sz.height() + margin > ret.height())
1614 ret.setHeight(sz.height() + margin);
1615 }
1616 if (as_gui_menubar) {
1618 opt.rect = rect();
1619 opt.menuRect = rect();
1621 opt.menuItemType = QStyleOptionMenuItem::Normal;
1623 opt.palette = palette();
1624 return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, ret, this);
1625 }
1626 return ret;
1627}
1628
1633{
1634 Q_D(const QMenuBar);
1635 const bool as_gui_menubar = !isNativeMenuBar();
1636
1637 const_cast<QMenuBarPrivate*>(d)->updateGeometries();
1638 int height = 0;
1639 const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
1640 int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
1641 int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
1642 if (as_gui_menubar) {
1643 for (int i = 0; i < d->actionRects.size(); ++i)
1644 height = qMax(height, d->actionRects.at(i).height());
1645 if (height) //there is at least one non-null item
1646 height += spaceBelowMenuBar;
1647 height += 2*fw;
1648 height += 2*vmargin;
1649 }
1650 int margin = 2*vmargin + 2*fw + spaceBelowMenuBar;
1651 if (d->leftWidget)
1652 height = qMax(d->leftWidget->sizeHint().height() + margin, height);
1653 if (d->rightWidget)
1654 height = qMax(d->rightWidget->sizeHint().height() + margin, height);
1655 if (as_gui_menubar) {
1657 opt.initFrom(this);
1658 opt.menuRect = rect();
1660 opt.menuItemType = QStyleOptionMenuItem::Normal;
1662 return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); //not pretty..
1663 }
1664 return height;
1665}
1666
1671{
1672 Q_Q(QMenuBar);
1673 QAction *act = actions.at(id);
1674 if (act && act->menu()) {
1675 if (QPlatformMenu *platformMenu = act->menu()->platformMenu()) {
1676 platformMenu->showPopup(q->windowHandle(), actionRects.at(id), nullptr);
1677 return;
1678 }
1679 }
1680
1682 setCurrentAction(act, true, true);
1683 if (act && !act->menu()) {
1685 //100 is the same as the default value in QPushButton::animateClick
1686 autoReleaseTimer.start(100, q);
1687 } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) {
1688 // When we open a menu using a shortcut, we should end up in keyboard state
1689 setKeyboardMode(true);
1690 }
1691}
1692
1694{
1695 Q_Q(QMenuBar);
1696 itemsDirty = true;
1697 if (q->isVisible()) {
1699 q->update();
1700 }
1701}
1702
1717{
1718 Q_D(QMenuBar);
1719 switch (corner) {
1720 case Qt::TopLeftCorner:
1721 if (d->leftWidget)
1722 d->leftWidget->removeEventFilter(this);
1723 d->leftWidget = w;
1724 break;
1725 case Qt::TopRightCorner:
1726 if (d->rightWidget)
1727 d->rightWidget->removeEventFilter(this);
1728 d->rightWidget = w;
1729 break;
1730 default:
1731 qWarning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported");
1732 return;
1733 }
1734
1735 if (w) {
1736 w->setParent(this);
1737 w->installEventFilter(this);
1738 }
1739
1740 d->_q_updateLayout();
1741}
1742
1751{
1752 Q_D(const QMenuBar);
1753 QWidget *w = nullptr;
1754 switch(corner) {
1755 case Qt::TopLeftCorner:
1756 w = d->leftWidget;
1757 break;
1758 case Qt::TopRightCorner:
1759 w = d->rightWidget;
1760 break;
1761 default:
1762 qWarning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported");
1763 break;
1764 }
1765
1766 return w;
1767}
1768
1786void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
1787{
1788 Q_D(QMenuBar);
1789 if (nativeMenuBar != bool(d->platformMenuBar)) {
1790 if (!nativeMenuBar) {
1791 delete d->platformMenuBar;
1792 d->platformMenuBar = nullptr;
1793 d->itemsDirty = true;
1794 } else {
1795 if (!d->platformMenuBar)
1796 d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
1797 }
1798
1800 if (!nativeMenuBar && parentWidget())
1801 setVisible(true);
1802 }
1803}
1804
1806{
1807 Q_D(const QMenuBar);
1808 return bool(d->platformMenuBar);
1809}
1810
1815{
1816 Q_D(const QMenuBar);
1817 return d->platformMenuBar;
1818}
1819
1848// for private slots
1849
1851
1852#include <moc_qmenubar.cpp>
void setIcon(const QIcon &icon)
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
ActionEvent
This enum type is used when calling QAction::activate()
Definition qaction.h:175
@ Trigger
Definition qaction.h:175
@ Hover
Definition qaction.h:175
T menu() const
Returns the menu contained by this action.
Definition qaction.h:186
bool isSeparator() const
Returns true if this action is a separator action; otherwise it returns false.
Definition qaction.cpp:585
bool isVisible() const
Definition qaction.cpp:1018
void setSeparator(bool b)
If b is true then this action will be considered a separator.
Definition qaction.cpp:569
bool showStatusText(QObject *object=nullptr)
Updates the relevant status bar for the UI represented by object by sending a QStatusTipEvent.
Definition qaction.cpp:736
void activate(ActionEvent event)
Sends the relevant signals for ActionEvent event.
Definition qaction.cpp:1082
QString text
the action's descriptive text
Definition qaction.h:39
QIcon icon
the action's icon
Definition qaction.h:38
bool isEnabled() const
Definition qaction.cpp:971
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
static QWidget * activePopupWidget()
Returns the active popup widget.
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
void stop()
Stops the timer.
\inmodule QtCore
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
\inmodule QtCore
Definition qcoreevent.h:45
virtual void setAccepted(bool accepted)
Definition qcoreevent.h:307
@ QueryWhatsThis
Definition qcoreevent.h:169
@ ActionRemoved
Definition qcoreevent.h:153
@ ParentChange
Definition qcoreevent.h:80
@ ActionAdded
Definition qcoreevent.h:152
@ LayoutDirectionChange
Definition qcoreevent.h:124
@ ShortcutOverride
Definition qcoreevent.h:158
@ FocusOut
Definition qcoreevent.h:67
@ StyleChange
Definition qcoreevent.h:136
@ ActionChanged
Definition qcoreevent.h:151
@ FontChange
Definition qcoreevent.h:133
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ FocusIn
Definition qcoreevent.h:66
@ ActivationChange
Definition qcoreevent.h:135
@ MouseButtonPress
Definition qcoreevent.h:60
@ HideToParent
Definition qcoreevent.h:86
@ ApplicationFontChange
Definition qcoreevent.h:91
@ ShowToParent
Definition qcoreevent.h:85
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition qcoreevent.h:310
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\reentrant \inmodule QtGui
int midLineWidth
the width of the mid-line
Definition qframe.h:23
int lineWidth
the line width
Definition qframe.h:22
static QPlatformTheme * platformTheme()
QScreen * primaryScreen
the primary (or default) screen of the application.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition qevent.h:788
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition qevent.h:798
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:1019
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
QString text() const
Returns the Unicode text that this key generated.
Definition qevent.h:443
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
qsizetype size() const noexcept
Definition qlist.h:397
QList< T > & fill(parameter_type t, qsizetype size=-1)
Definition qlist.h:903
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
T value(qsizetype i) const
Definition qlist.h:664
void reserve(qsizetype size)
Definition qlist.h:753
void resize(qsizetype size)
Definition qlist.h:403
void append(parameter_type t)
Definition qlist.h:458
void clear()
Definition qlist.h:434
QSize sizeHint() const override
Definition qmenubar.cpp:71
void paintEvent(QPaintEvent *) override
\reimp
Definition qmenubar.cpp:60
QMenuBarExtension(QWidget *parent)
Definition qmenubar.cpp:49
QPlatformMenu * findInsertionPlatformMenu(const QAction *action)
QMenuBarExtension * extension
Definition qmenubar_p.h:83
QPlatformMenu * getPlatformMenu(const QAction *action)
QPointer< QAction > currentAction
Definition qmenubar_p.h:57
QAction * actionAt(QPoint p) const
Definition qmenubar.cpp:81
void calcActionRects(int max_width, int start) const
Definition qmenubar.cpp:384
void _q_internalShortcutActivated(int)
void _q_actionTriggered()
Definition qmenubar.cpp:496
QList< QRect > actionRects
Definition qmenubar_p.h:51
void _q_updateLayout()
QPointer< QMenu > activeMenu
Definition qmenubar_p.h:65
void copyActionToPlatformMenu(const QAction *e, QPlatformMenu *menu)
void focusFirstAction()
Definition qmenubar.cpp:238
QAction * getNextAction(const int start, const int increment) const
Definition qmenubar.cpp:691
QPlatformMenuBar * platformMenuBar
Definition qmenubar_p.h:100
void popupAction(QAction *, bool)
Definition qmenubar.cpp:275
void setCurrentAction(QAction *, bool=false, bool=false)
Definition qmenubar.cpp:341
QPointer< QWidget > keyboardFocusWidget
Definition qmenubar_p.h:71
QPointer< QWidget > rightWidget
Definition qmenubar_p.h:82
QList< QPointer< QWidget > > oldParents
Definition qmenubar_p.h:93
int indexOf(QAction *act) const
Definition qmenubar_p.h:105
QBasicTimer autoReleaseTimer
Definition qmenubar_p.h:99
void activateAction(QAction *, QAction::ActionEvent)
Definition qmenubar.cpp:480
QPointer< QWidget > leftWidget
Definition qmenubar_p.h:82
QList< QAction * > hiddenActions
Definition qmenubar_p.h:95
void updateGeometries()
Definition qmenubar.cpp:129
void handleReparent()
QRect menuRect(bool) const
Definition qmenubar.cpp:90
bool isVisible(QAction *action)
Definition qmenubar.cpp:124
void _q_actionHovered()
Definition qmenubar.cpp:504
void setKeyboardMode(bool)
Definition qmenubar.cpp:249
QRect actionRect(QAction *) const
Definition qmenubar.cpp:225
QList< int > shortcutIndexMap
Definition qmenubar_p.h:50
The QMenuBar class provides a horizontal menu bar.
Definition qmenubar.h:20
QWidget * cornerWidget(Qt::Corner corner=Qt::TopRightCorner) const
Returns the widget on the left of the first or on the right of the last menu item,...
void hovered(QAction *action)
This signal is emitted when a menu action is highlighted; action is the action that caused the event ...
void setActiveAction(QAction *action)
Definition qmenubar.cpp:830
QAction * addMenu(QMenu *menu)
Appends menu to the menu bar.
Definition qmenubar.cpp:768
QMenuBar(QWidget *parent=nullptr)
Constructs a menu bar with parent parent.
Definition qmenubar.cpp:715
void setVisible(bool visible) override
\reimp
Definition qmenubar.cpp:946
QAction * actionAt(const QPoint &) const
Returns the QAction at pt.
void setNativeMenuBar(bool nativeMenuBar)
virtual void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const
Initialize option with the values from the menu bar and information from action.
Definition qmenubar.cpp:527
bool event(QEvent *) override
\reimp
void leaveEvent(QEvent *) override
\reimp
QSize sizeHint() const override
\reimp
bool nativeMenuBar
Whether or not a menubar will be used as a native menubar on platforms that support it.
Definition qmenubar.h:24
void focusInEvent(QFocusEvent *) override
\reimp
void changeEvent(QEvent *) override
\reimp
void focusOutEvent(QFocusEvent *) override
\reimp
void mousePressEvent(QMouseEvent *) override
\reimp
Definition qmenubar.cpp:959
void timerEvent(QTimerEvent *) override
\reimp
void mouseMoveEvent(QMouseEvent *) override
\reimp
bool isNativeMenuBar() const
void setCornerWidget(QWidget *w, Qt::Corner corner=Qt::TopRightCorner)
This sets the given widget to be shown directly on the left of the first menu item,...
void paintEvent(QPaintEvent *) override
\reimp
Definition qmenubar.cpp:893
QRect actionGeometry(QAction *) const
Returns the geometry of action act as a QRect.
QAction * insertSeparator(QAction *before)
This convenience function creates a new separator action, i.e.
Definition qmenubar.cpp:794
int heightForWidth(int) const override
\reimp
QPlatformMenuBar * platformMenuBar()
QAction * addSeparator()
Appends a separator to the menu.
Definition qmenubar.cpp:778
void clear()
Removes all the actions from the menu bar.
Definition qmenubar.cpp:849
QAction * activeAction() const
Returns the QAction that is currently highlighted, if any, else \nullptr.
Definition qmenubar.cpp:819
bool eventFilter(QObject *, QEvent *) override
\reimp
~QMenuBar()
Destroys the menu bar.
Definition qmenubar.cpp:725
void resizeEvent(QResizeEvent *) override
\reimp
Definition qmenubar.cpp:883
void actionEvent(QActionEvent *) override
\reimp
void setDefaultUp(bool)
Definition qmenubar.cpp:868
QSize minimumSizeHint() const override
\reimp
void mouseReleaseEvent(QMouseEvent *) override
\reimp
Definition qmenubar.cpp:991
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition qwidget.cpp:3117
void keyPressEvent(QKeyEvent *) override
\reimp
void triggered(QAction *action)
This signal is emitted when an action in a menu belonging to this menubar is triggered as a result of...
bool isDefaultUp() const
Definition qmenubar.cpp:874
QAction * insertMenu(QAction *before, QMenu *menu)
This convenience function inserts menu before action before and returns the menus menuAction().
Definition qmenubar.cpp:808
static QMenuPrivate * get(QMenu *m)
Definition qmenu_p.h:309
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
QSize sizeHint() const override
\reimp
Definition qmenu.cpp:2269
void clear()
Removes all the menu's actions.
Definition qmenu.cpp:2225
void setIcon(const QIcon &icon)
Definition qmenu.cpp:1116
void popup(const QPoint &pos, QAction *at=nullptr)
Displays the menu so that the action atAction will be at the specified global position p.
Definition qmenu.cpp:2310
QAction * menuAction() const
Returns the action associated with this menu.
Definition qmenu.cpp:1069
\inmodule QtGui
Definition qevent.h:196
Qt::MouseEventSource source() const
Definition qevent.cpp:801
\inmodule QtCore
Definition qobject.h:103
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
Definition qobject.cpp:2339
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void removeEventFilter(QObject *obj)
Removes an event filter object obj from this object.
Definition qobject.cpp:2370
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1470
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
const QRect & rect() const
Returns the rectangle that needs to be updated.
Definition qevent.h:492
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
@ Disabled
Definition qpalette.h:49
virtual QPlatformMenu * createMenu() const
virtual void handleReparent(QWindow *newParentWindow)=0
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
bool intersects(const QRect &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel...
Definition qrect.cpp:1069
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:373
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition qrect.h:164
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:182
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:176
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:855
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:173
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:179
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QRect virtualGeometry
the pixel geometry of the virtual desktop to which this screen belongs
Definition qscreen.h:47
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
QPointF globalPosition() const
Returns the position of the point in this event on the screen or virtual desktop.
Definition qevent.h:123
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Definition qevent.h:119
Qt::MouseButton button() const
Returns the button that caused the event.
Definition qevent.h:116
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition qevent.h:117
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr int & rheight() noexcept
Returns a reference to the height.
Definition qsize.h:157
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition qsize.h:192
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
Definition qsize.h:136
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:124
The QStatusTipEvent class provides an event that is used to show messages in a status bar.
Definition qevent.h:808
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4517
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
ButtonFeatures features
\variable QStyleOptionFocusRect::backgroundColor
\variable QStyleOptionProgressBar::minimum
\variable QStyleOptionDockWidget::title
QStyle::State state
QPalette palette
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ State_Sunken
Definition qstyle.h:69
@ State_HasFocus
Definition qstyle.h:75
@ State_Enabled
Definition qstyle.h:67
@ State_Selected
Definition qstyle.h:82
@ State_None
Definition qstyle.h:66
@ CT_MenuBar
Definition qstyle.h:556
@ CT_MenuBarItem
Definition qstyle.h:555
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_MainWindow_SpaceBelowMenuBar
Definition qstyle.h:597
@ SH_MenuBar_AltKeyNavigation
Definition qstyle.h:603
@ SH_Menu_AllowActiveAndDisabled
Definition qstyle.h:599
@ SH_MenuBar_MouseTracking
Definition qstyle.h:606
@ SH_DrawMenuBarSeparator
Definition qstyle.h:632
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
@ SP_ToolBarHorizontalExtensionButton
Definition qstyle.h:744
@ CE_MenuBarItem
Definition qstyle.h:197
@ CE_MenuBarEmptyArea
Definition qstyle.h:198
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
Definition qstyle.cpp:2143
@ PM_MenuBarHMargin
Definition qstyle.h:460
@ PM_MenuBarPanelWidth
Definition qstyle.h:457
@ PM_SmallIconSize
Definition qstyle.h:495
@ PM_MenuBarItemSpacing
Definition qstyle.h:458
@ PM_ToolBarExtensionExtent
Definition qstyle.h:488
@ PM_MenuBarVMargin
Definition qstyle.h:459
@ CC_ToolButton
Definition qstyle.h:336
@ PE_PanelMenuBar
Definition qstyle.h:120
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
\inmodule QtCore
Definition qcoreevent.h:366
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition qcoreevent.h:370
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:20
void setAutoRaise(bool enable)
virtual void initStyleOption(QStyleOptionToolButton *option) const
Initialize option with the values from this QToolButton.
static void showText(const QPoint &pos, const QString &text, QWidget *w=nullptr)
Shows text as a "What's This?" window, at global position pos.
static bool inWhatsThisMode()
Returns true if the user interface is in "What's This?" mode; otherwise returns false.
QList< QAction * > actions
Definition qwidget_p.h:709
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.
QWidget * window() const
Returns the window for this widget, i.e.
Definition qwidget.cpp:4313
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:886
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
void setEnabled(bool)
Definition qwidget.cpp:3358
QPalette palette
the widget's palette
Definition qwidget.h:132
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
void setMouseTracking(bool enable)
Definition qwidget.h:853
QFontMetrics fontMetrics() const
Returns the font metrics for the widget's current font.
Definition qwidget.h:847
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition qwidget.cpp:6828
void setFocusPolicy(Qt::FocusPolicy policy)
Definition qwidget.cpp:7822
void hide()
Hides the widget.
Definition qwidget.cpp:8135
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget's actions.
Definition qwidget.cpp:3207
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
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
void insertAction(QAction *before, QAction *action)
Inserts the action action to this widget's list of actions, before the action before.
Definition qwidget.cpp:3142
void ensurePolished() const
Ensures that the widget and its children have been polished by QStyle (i.e., have a proper font and p...
bool isEnabled() const
Definition qwidget.h:814
void update()
Updates the widget unless updates are disabled or the widget is hidden.
QWindow * windowHandle() const
If this is a native widget, return the associated QWindow.
Definition qwidget.cpp:2483
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9382
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
bool isRightToLeft() const
Definition qwidget.h:419
void addActions(const QList< QAction * > &actions)
Appends the actions actions to this widget's list of actions.
Definition qwidget.cpp:3127
bool event(QEvent *event) override
This is the main event handler; it handles event event.
Definition qwidget.cpp:8866
QStyle * style() const
Definition qwidget.cpp:2600
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
bool hasFocus() const
Definition qwidget.cpp:6446
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
void removeAction(QAction *action)
Removes the action action from this widget's list of actions.
Definition qwidget.cpp:3186
bool isVisible() const
Definition qwidget.h:874
bool visible
whether the widget is visible
Definition qwidget.h:144
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
rect
[4]
QStyleOptionButton opt
Combined button and popup list for selecting options.
@ TopRightCorner
@ TopLeftCorner
@ LeftButton
Definition qnamespace.h:58
@ WA_CustomWhatsThis
Definition qnamespace.h:313
@ WA_NoMouseReplay
Definition qnamespace.h:320
@ NoFocus
Definition qnamespace.h:107
@ TextShowMnemonic
Definition qnamespace.h:173
@ MouseEventNotSynthesized
@ Key_Tab
Definition qnamespace.h:664
@ Key_Return
Definition qnamespace.h:667
@ Key_Right
Definition qnamespace.h:679
@ Key_Enter
Definition qnamespace.h:668
@ Key_Space
Definition qnamespace.h:513
@ Key_Backtab
Definition qnamespace.h:665
@ Key_Left
Definition qnamespace.h:677
@ Key_Alt
Definition qnamespace.h:686
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
@ Key_Meta
Definition qnamespace.h:685
@ MetaModifier
@ AltModifier
@ AA_DontUseNativeMenuBar
Definition qnamespace.h:431
@ NoFocusReason
@ MenuBarFocusReason
static jboolean copy(JNIEnv *, jobject)
NSMenu QCocoaMenu * platformMenu
#define Q_FALLTHROUGH()
#define qApp
AudioChannelLayoutTag tag
#define qWarning
Definition qlogging.h:166
return ret
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLboolean GLboolean GLboolean b
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLint left
GLuint start
GLint first
GLint y
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLuint GLenum option
#define emit
size_t quintptr
Definition qtypes.h:167
ptrdiff_t qsizetype
Definition qtypes.h:165
QWidget * qobject_cast< QWidget * >(QObject *o)
Definition qwidget.h:786
QtConcurrent::task([]{ qDebug("Hello, world!");}).spawn(FutureResult void increment(QPromise< int > &promise, int i)
[10]
QString title
[35]
QFrame frame
[0]
QMenu menu
[5]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:962
bool contains(const AT &t) const noexcept
Definition qlist.h:45