QtBase  v6.3.1
qapplication.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 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 "qplatformdefs.h"
42 #include "qapplication.h"
43 #include "qclipboard.h"
44 #include "qcursor.h"
45 #include "qdir.h"
46 #include "qevent.h"
47 #include "qfile.h"
48 #include "qfileinfo.h"
49 #if QT_CONFIG(graphicsview)
50 #include "qgraphicsscene.h"
51 #include <QtWidgets/qgraphicsproxywidget.h>
52 #endif
53 #include "qhash.h"
54 #include "qset.h"
55 #include "qlayout.h"
56 #include "qpixmapcache.h"
57 #include "qstyle.h"
58 #include "qstyleoption.h"
59 #include "qstylefactory.h"
60 #if QT_CONFIG(tooltip)
61 #include "qtooltip.h"
62 #endif
63 #include "qtranslator.h"
64 #include "qvariant.h"
65 #include "qwidget.h"
66 #if QT_CONFIG(draganddrop)
67 #include <private/qdnd_p.h>
68 #endif
69 #include "private/qguiapplication_p.h"
70 #include "qcolormap.h"
71 #include "qdebug.h"
72 #include "private/qstylesheetstyle_p.h"
73 #include "private/qstyle_p.h"
74 #if QT_CONFIG(messagebox)
75 #include "qmessagebox.h"
76 #endif
77 #include "qwidgetwindow_p.h"
78 #include <QtGui/qstylehints.h>
79 #include <QtGui/qinputmethod.h>
80 #include <QtGui/private/qwindow_p.h>
81 #include <QtGui/qpointingdevice.h>
82 #include <QtGui/private/qpointingdevice_p.h>
83 #include <qpa/qplatformtheme.h>
84 #if QT_CONFIG(whatsthis)
85 #include <QtWidgets/QWhatsThis>
86 #endif
87 
88 #include "private/qkeymapper_p.h"
89 #include "private/qaccessiblewidgetfactory_p.h"
90 
91 #include <qthread.h>
92 #include <private/qthread_p.h>
93 
94 #include <QtGui/private/qevent_p.h>
95 #include <QtGui/private/qeventpoint_p.h>
96 #include <private/qfont_p.h>
97 #if QT_CONFIG(action)
98 #include <private/qaction_p.h>
99 #endif
100 
101 #include <stdlib.h>
102 
103 #include "qapplication_p.h"
104 #include "qwidget_p.h"
105 
106 #include "qgesture.h"
107 #include "private/qgesturemanager_p.h"
108 #include <qpa/qplatformfontdatabase.h>
109 
110 #include "qdatetime.h"
111 
112 #include <qpa/qplatformwindow.h>
113 
114 #include <qtwidgets_tracepoints_p.h>
115 
116 #include <algorithm>
117 #include <iterator>
118 
119 //#define ALIEN_DEBUG
120 
121 static void initResources()
122 {
123  Q_INIT_RESOURCE(qstyle);
124 
125 #if QT_CONFIG(messagebox)
126  Q_INIT_RESOURCE(qmessagebox);
127 #endif
128 }
129 
131 
132 // Helper macro for static functions to check on the existence of the application class.
133 #define CHECK_QAPP_INSTANCE(...) \
134  if (Q_LIKELY(QCoreApplication::instance())) { \
135  } else { \
136  qWarning("Must construct a QApplication first."); \
137  return __VA_ARGS__; \
138  }
139 
140 Q_CORE_EXPORT void qt_call_post_routines();
141 Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
142 
143 QApplicationPrivate *QApplicationPrivate::self = nullptr;
144 
146 
148  : QApplicationPrivateBase(argc, argv, flags)
149 {
150  application_type = QApplicationPrivate::Gui;
151 
152 #ifndef QT_NO_GESTURES
153  gestureManager = nullptr;
154  gestureWidget = nullptr;
155 #endif // QT_NO_GESTURES
156 
157  if (!self)
158  self = this;
159 }
160 
162 {
163  if (self == this)
164  self = nullptr;
165 }
166 
168 {
170 }
171 
317 {
319  if (const QWidgetWindow *widgetWindow = qobject_cast<const QWidgetWindow *>(window))
320  return widgetWindow->widget();
321  }
322  return nullptr;
323 }
324 
335 void qt_cleanup();
336 
337 QStyle *QApplicationPrivate::app_style = nullptr; // default application style
338 #ifndef QT_NO_STYLE_STYLESHEET
339 QString QApplicationPrivate::styleSheet; // default application stylesheet
340 #endif
342 
343 QFont *QApplicationPrivate::sys_font = nullptr; // default system font
344 QFont *QApplicationPrivate::set_font = nullptr; // default font set by programmer
345 
346 QWidget *QApplicationPrivate::main_widget = nullptr; // main application widget
347 QWidget *QApplicationPrivate::focus_widget = nullptr; // has keyboard input focus
348 QWidget *QApplicationPrivate::hidden_focus_widget = nullptr; // will get keyboard input focus after show()
349 QWidget *QApplicationPrivate::active_window = nullptr; // toplevel with keyboard focus
350 #if QT_CONFIG(wheelevent)
351 QPointer<QWidget> QApplicationPrivate::wheel_widget;
352 #endif
353 bool qt_in_tab_key_event = false;
357 #ifdef QT_KEYPAD_NAVIGATION
358 Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
359 QWidget *QApplicationPrivate::oldEditFocus = nullptr;
360 #endif
361 
362 inline bool QApplicationPrivate::isAlien(QWidget *widget)
363 {
364  return widget && !widget->isWindow();
365 }
366 
367 bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
368 {
370 }
371 
372 // ######## move to QApplicationPrivate
373 // Default fonts (per widget type)
374 Q_GLOBAL_STATIC(FontHash, app_fonts)
375 // Exported accessor for use outside of this file
376 FontHash *qt_app_fonts_hash() { return app_fonts(); }
377 
378 QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus
379 
380 QWidget *qt_desktopWidget = nullptr; // root window widgets
381 
386 {
387  if (styleOverride.isEmpty() && qEnvironmentVariableIsSet("QT_STYLE_OVERRIDE"))
388  styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
389 
390  // process platform-indep command line
391  if (qt_is_tty_app || !argc)
392  return;
393 
394  int i, j;
395 
396  j = 1;
397  for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
398  if (!argv[i])
399  continue;
400  if (*argv[i] != '-') {
401  argv[j++] = argv[i];
402  continue;
403  }
404  const char *arg = argv[i];
405  if (arg[1] == '-') // startsWith("--")
406  ++arg;
407  if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
408  // obsolete argument
409 #ifndef QT_NO_STYLE_STYLESHEET
410  } else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
411  styleSheet = QLatin1String("file:///");
413  } else if (strncmp(arg, "-stylesheet=", 12) == 0) {
414  styleSheet = QLatin1String("file:///");
416 #endif
417  } else if (qstrcmp(arg, "-widgetcount") == 0) {
418  widgetCount = true;
419  } else {
420  argv[j++] = argv[i];
421  }
422  }
423 
424  if (j < argc) {
425  argv[j] = nullptr;
426  argc = j;
427  }
428 }
429 
475 #ifdef Q_QDOC
476 QApplication::QApplication(int &argc, char **argv)
477 #else
478 QApplication::QApplication(int &argc, char **argv, int _internal)
479 #endif
480  : QGuiApplication(*new QApplicationPrivate(argc, argv, _internal))
481 {
482  Q_D(QApplication);
483  d->init();
484 }
485 
490 {
491 #if defined(Q_OS_MACOS)
492  QMacAutoReleasePool pool;
493 #endif
494 
496 
497  initResources();
498 
499  qt_is_tty_app = (application_type == QApplicationPrivate::Tty);
500  process_cmdline();
501 
502  // Must be called before initialize()
507 
508  initialize();
509  eventDispatcher->startingUp();
510 
511 #ifndef QT_NO_ACCESSIBILITY
512  // factory for accessible interfaces for widgets shipped with Qt
514 #endif
515 
516 }
517 
519 {
520 #if QT_CONFIG(tooltip)
522  QToolTip::setPalette(*toolTipPalette);
523 #endif
524 }
525 
526 extern void qRegisterWidgetsVariant();
527 
532 {
533  is_app_running = false; // Starting up.
534 
537 
538  // needed for a static build.
540 
541  // needed for widgets in QML
543 
544  if (application_type != QApplicationPrivate::Tty) {
545  if (!styleOverride.isEmpty()) {
546  if (auto *style = QStyleFactory::create(styleOverride.toLower())) {
548  } else {
549  qWarning("QApplication: invalid style override '%s' passed, ignoring it.\n"
550  "\tAvailable styles: %s", qPrintable(styleOverride),
551  qPrintable(QStyleFactory::keys().join(QLatin1String(", "))));
552  }
553  }
554 
555  // Trigger default style if none was set already
557  }
558 
559  if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0)
561 
562  if (!qt_is_tty_app)
564 
568  }
569 
570  is_app_running = true; // no longer starting up
571 }
572 
574 {
576  if (!theme)
577  return;
578  FontHash *fontHash = app_fonts();
579  fontHash->clear();
580 
581  if (const QFont *font = theme->font(QPlatformTheme::MenuFont))
582  fontHash->insert(QByteArrayLiteral("QMenu"), *font);
583  if (const QFont *font = theme->font(QPlatformTheme::MenuBarFont))
584  fontHash->insert(QByteArrayLiteral("QMenuBar"), *font);
585  if (const QFont *font = theme->font(QPlatformTheme::MenuItemFont))
586  fontHash->insert(QByteArrayLiteral("QMenuItem"), *font);
587  if (const QFont *font = theme->font(QPlatformTheme::MessageBoxFont))
588  fontHash->insert(QByteArrayLiteral("QMessageBox"), *font);
589  if (const QFont *font = theme->font(QPlatformTheme::LabelFont))
590  fontHash->insert(QByteArrayLiteral("QLabel"), *font);
591  if (const QFont *font = theme->font(QPlatformTheme::TipLabelFont))
592  fontHash->insert(QByteArrayLiteral("QTipLabel"), *font);
593  if (const QFont *font = theme->font(QPlatformTheme::TitleBarFont))
594  fontHash->insert(QByteArrayLiteral("QTitleBar"), *font);
595  if (const QFont *font = theme->font(QPlatformTheme::StatusBarFont))
596  fontHash->insert(QByteArrayLiteral("QStatusBar"), *font);
598  fontHash->insert(QByteArrayLiteral("QMdiSubWindowTitleBar"), *font);
599  if (const QFont *font = theme->font(QPlatformTheme::DockWidgetTitleFont))
600  fontHash->insert(QByteArrayLiteral("QDockWidgetTitle"), *font);
601  if (const QFont *font = theme->font(QPlatformTheme::PushButtonFont))
602  fontHash->insert(QByteArrayLiteral("QPushButton"), *font);
603  if (const QFont *font = theme->font(QPlatformTheme::CheckBoxFont))
604  fontHash->insert(QByteArrayLiteral("QCheckBox"), *font);
605  if (const QFont *font = theme->font(QPlatformTheme::RadioButtonFont))
606  fontHash->insert(QByteArrayLiteral("QRadioButton"), *font);
607  if (const QFont *font = theme->font(QPlatformTheme::ToolButtonFont))
608  fontHash->insert(QByteArrayLiteral("QToolButton"), *font);
609  if (const QFont *font = theme->font(QPlatformTheme::ItemViewFont))
610  fontHash->insert(QByteArrayLiteral("QAbstractItemView"), *font);
611  if (const QFont *font = theme->font(QPlatformTheme::ListViewFont))
612  fontHash->insert(QByteArrayLiteral("QListView"), *font);
613  if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont))
614  fontHash->insert(QByteArrayLiteral("QHeaderView"), *font);
615  if (const QFont *font = theme->font(QPlatformTheme::ListBoxFont))
616  fontHash->insert(QByteArrayLiteral("QListBox"), *font);
617  if (const QFont *font = theme->font(QPlatformTheme::ComboMenuItemFont))
618  fontHash->insert(QByteArrayLiteral("QComboMenuItem"), *font);
619  if (const QFont *font = theme->font(QPlatformTheme::ComboLineEditFont))
620  fontHash->insert(QByteArrayLiteral("QComboLineEdit"), *font);
621  if (const QFont *font = theme->font(QPlatformTheme::SmallFont))
622  fontHash->insert(QByteArrayLiteral("QSmallFont"), *font);
623  if (const QFont *font = theme->font(QPlatformTheme::MiniFont))
624  fontHash->insert(QByteArrayLiteral("QMiniFont"), *font);
625 }
626 
627 /*****************************************************************************
628  Functions returning the active popup and modal widgets.
629  *****************************************************************************/
630 
647 {
650 }
651 
652 
668 {
669  QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow());
670  return widgetWindow ? widgetWindow->widget() : nullptr;
671 }
672 
679 {
680  Q_D(QApplication);
681 
682  //### this should probable be done even later
684 
685  // kill timers before closing down the dispatcher
686  d->toolTipWakeUp.stop();
687  d->toolTipFallAsleep.stop();
688 
689  QApplicationPrivate::is_app_closing = true;
690  QApplicationPrivate::is_app_running = false;
691 
692  delete QWidgetPrivate::mapper;
693  QWidgetPrivate::mapper = nullptr;
694 
695  // delete all widgets
698  QWidgetPrivate::allWidgets = nullptr;
699  for (QWidgetSet::ConstIterator it = mySet->constBegin(), cend = mySet->constEnd(); it != cend; ++it) {
700  QWidget *w = *it;
701  if (!w->parent()) // window
702  w->destroy(true, true);
703  }
704  delete mySet;
705  }
706 
707  delete qt_desktopWidget;
708  qt_desktopWidget = nullptr;
709 
711 
716  app_fonts()->clear();
717 
720 
721 #if QT_CONFIG(draganddrop)
722  if (!qt_is_tty_app)
723  delete QDragManager::self();
724 #endif
725 
726  d->cleanupMultitouch();
727 
728  qt_cleanup();
729 
731  qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
732 
733  QApplicationPrivate::obey_desktop_settings = true;
734 
737 }
738 
740 {
743 
744  QApplicationPrivate::active_window = nullptr; //### this should not be necessary
745 }
746 
758 {
760  if (!window)
761  return nullptr;
762 
763  QWidget *child = nullptr;
764 
765  if (!window->testAttribute(Qt::WA_TransparentForMouseEvents))
766  child = window->childAt(window->mapFromGlobal(p));
767 
768  if (child)
769  return child;
770 
771  if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) {
772  //shoot a hole in the widget and try once again,
773  //suboptimal on Qt for Embedded Linux where we do
774  //know the stacking order of the toplevels.
775  int x = p.x();
776  int y = p.y();
777  QRegion oldmask = window->mask();
778  QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
779  QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
780  - QRegion(wpoint.x(), wpoint.y(), 1, 1);
781  window->setMask(newmask);
782  QWidget *recurse = nullptr;
783  if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
784  recurse = widgetAt(x, y);
785  if (oldmask.isEmpty())
786  window->clearMask();
787  else
788  window->setMask(oldmask);
789  return recurse;
790  }
791  return window;
792 }
793 
807 {
808  if ((event->type() == QEvent::UpdateRequest
809  || event->type() == QEvent::LayoutRequest
810  || event->type() == QEvent::Resize
811  || event->type() == QEvent::Move
812  || event->type() == QEvent::LanguageChange)) {
813  for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
814  const QPostEvent &cur = *it;
815  if (cur.receiver != receiver || cur.event == nullptr || cur.event->type() != event->type())
816  continue;
817  if (cur.event->type() == QEvent::LayoutRequest
818  || cur.event->type() == QEvent::UpdateRequest) {
819  ;
820  } else if (cur.event->type() == QEvent::Resize) {
821  static_cast<QResizeEvent *>(cur.event)->m_size =
822  static_cast<const QResizeEvent *>(event)->size();
823  } else if (cur.event->type() == QEvent::Move) {
824  static_cast<QMoveEvent *>(cur.event)->m_pos =
825  static_cast<const QMoveEvent *>(event)->pos();
826  } else if (cur.event->type() == QEvent::LanguageChange) {
827  ;
828  } else {
829  continue;
830  }
831  delete event;
832  return true;
833  }
834  return false;
835  }
836  return QGuiApplication::compressEvent(event, receiver, postedEvents);
837 }
838 
866 {
868 }
869 
871 {
873 }
874 
875 #ifndef QT_NO_STYLE_STYLESHEET
876 
878 {
880 }
881 
882 void QApplication::setStyleSheet(const QString& styleSheet)
883 {
886  if (styleSheet.isEmpty()) { // application style sheet removed
887  if (!styleSheetStyle)
888  return; // there was no stylesheet before
889  setStyle(styleSheetStyle->base);
890  } else if (styleSheetStyle) { // style sheet update, just repolish
891  styleSheetStyle->repolish(qApp);
892  } else { // stylesheet set the first time
894  QApplicationPrivate::app_style->setParent(newStyleSheetStyle);
895  setStyle(newStyleSheetStyle);
896  }
897 }
898 
899 #endif // QT_NO_STYLE_STYLESHEET
900 
907 {
909  // Create default style
910  if (!qobject_cast<QApplication *>(QCoreApplication::instance())) {
911  Q_ASSERT(!"No style available without QApplication!");
912  return nullptr;
913  }
914 
915  auto &defaultStyle = QApplicationPrivate::app_style;
916 
918  if (!defaultStyle) {
919  const QStringList styles = QStyleFactory::keys();
920  for (const auto &style : styles) {
921  if ((defaultStyle = QStyleFactory::create(style)))
922  break;
923  }
924  }
925  if (!defaultStyle) {
926  Q_ASSERT(!"No styles available!");
927  return nullptr;
928  }
929 
930  // Take ownership of the style
931  defaultStyle->setParent(qApp);
932 
934 
935 #ifndef QT_NO_STYLE_STYLESHEET
936  if (!QApplicationPrivate::styleSheet.isEmpty()) {
937  qApp->setStyleSheet(QApplicationPrivate::styleSheet);
938  } else
939 #endif
940  {
941  defaultStyle->polish(qApp);
942  }
943  }
944 
946 }
947 
971 {
973  return;
974 
975  QWidgetList all = allWidgets();
976 
977  // clean up the old style
979  if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
980  for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
981  QWidget *w = *it;
982  if (!(w->windowType() == Qt::Desktop) && // except desktop
983  w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
985  }
986  }
987  }
989  }
990 
991  QStyle *old = QApplicationPrivate::app_style; // save
992 
993 #ifndef QT_NO_STYLE_STYLESHEET
995  // we have a stylesheet already and a new style is being set
996  QStyleSheetStyle *newStyleSheetStyle = new QStyleSheetStyle(style);
997  style->setParent(newStyleSheetStyle);
998  QApplicationPrivate::app_style = newStyleSheetStyle;
999  } else
1000 #endif // QT_NO_STYLE_STYLESHEET
1002  QApplicationPrivate::app_style->setParent(qApp); // take ownership
1003 
1004  // Take care of possible palette requirements of certain
1005  // styles. Do it before polishing the application since the
1006  // style might call QApplication::setPalette() itself.
1008 
1009  // The default widget font hash is based on the platform theme,
1010  // not the style, but the widget fonts could in theory have been
1011  // affected by polish of the previous style, without a proper
1012  // cleanup in unpolish, so reset it now before polishing the
1013  // new style.
1015 
1016  // initialize the application with the new style
1018 
1019  // re-polish existing widgets if necessary
1020  if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
1021  for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
1022  QWidget *w = *it;
1023  if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
1024  if (w->style() == QApplicationPrivate::app_style)
1025  QApplicationPrivate::app_style->polish(w); // repolish
1026 #ifndef QT_NO_STYLE_STYLESHEET
1027  else
1028  w->setStyleSheet(w->styleSheet()); // touch
1029 #endif
1030  }
1031  }
1032 
1033  for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) {
1034  QWidget *w = *it;
1035  if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
1038  w->update();
1039  }
1040  }
1041  }
1042 
1043 #ifndef QT_NO_STYLE_STYLESHEET
1044  if (QStyleSheetStyle *oldStyleSheetStyle = qt_styleSheet(old)) {
1045  oldStyleSheetStyle->deref();
1046  } else
1047 #endif
1048  if (old && old->parent() == qApp) {
1049  delete old;
1050  }
1051 
1056  }
1057 }
1058 
1076 {
1078  if (!s)
1079  return nullptr;
1080 
1081  setStyle(s);
1082  return s;
1083 }
1084 
1085 // Widget specific palettes
1087 
1089 {
1090  // Start out with a palette based on the style, in case there's no theme
1091  // available, or so that we can fill in missing roles in the theme.
1093 
1094  // Prefer theme palette if available, but fill in missing roles from style
1095  // for compatibility. Note that the style's standard palette is not prioritized
1096  // over the theme palette, as the documented way of applying the style's palette
1097  // is to set it explicitly using QApplication::setPalette().
1098  if (const QPalette *themePalette = platformTheme() ? platformTheme()->palette() : nullptr)
1099  palette = themePalette->resolve(palette);
1100 
1101  // Finish off by letting the application style polish the palette. This will
1102  // not result in the polished palette becoming a user-set palette, as the
1103  // resulting base palette is only used as a fallback, with the resolve mask
1104  // set to 0.
1105  if (app_style)
1107 
1108  return palette;
1109 }
1110 
1123 {
1124  auto &widgetPalettes = QApplicationPrivate::widgetPalettes;
1125  if (w && !widgetPalettes.isEmpty()) {
1126  auto it = widgetPalettes.constFind(w->metaObject()->className());
1127  const auto cend = widgetPalettes.constEnd();
1128  if (it != cend)
1129  return *it;
1130  for (it = widgetPalettes.constBegin(); it != cend; ++it) {
1131  if (w->inherits(it.key()))
1132  return it.value();
1133  }
1134  }
1135  return palette();
1136 }
1137 
1146 {
1147  auto &widgetPalettes = QApplicationPrivate::widgetPalettes;
1148  if (className && !widgetPalettes.isEmpty()) {
1149  auto it = widgetPalettes.constFind(className);
1150  if (it != widgetPalettes.constEnd())
1151  return *it;
1152  }
1153 
1154  return QGuiApplication::palette();
1155 }
1156 
1180 {
1181  if (className) {
1182  QPalette polishedPalette = palette;
1184  auto originalResolveMask = palette.resolveMask();
1185  QApplicationPrivate::app_style->polish(polishedPalette);
1186  polishedPalette.setResolveMask(originalResolveMask);
1187  }
1188 
1190  if (qApp)
1191  qApp->d_func()->handlePaletteChanged(className);
1192  } else {
1194  }
1195 }
1196 
1198 {
1199  if (!is_app_running || is_app_closing)
1200  return;
1201 
1202  // Setting the global application palette is documented to
1203  // reset any previously set class specific widget palettes.
1204  if (!className && !widgetPalettes.isEmpty())
1206 
1208 
1211  for (auto widget : widgets) {
1212  if (!widget->isWindow() && widget->inherits(className))
1214  }
1215 
1216 #if QT_CONFIG(graphicsview)
1217  for (auto scene : qAsConst(scene_list))
1219 #endif
1220 
1221  // Palette has been reset back to the default application palette,
1222  // so we need to reinitialize the widget palettes from the theme.
1223  if (!className && !testAttribute(Qt::AA_SetPalette))
1225 }
1226 
1228 {
1230  if (!platformTheme)
1231  return;
1232 
1234 
1235  struct ThemedWidget { const char *className; QPlatformTheme::Palette palette; };
1236 
1237  static const ThemedWidget themedWidgets[] = {
1238  { "QToolButton", QPlatformTheme::ToolButtonPalette },
1239  { "QAbstractButton", QPlatformTheme::ButtonPalette },
1240  { "QCheckBox", QPlatformTheme::CheckBoxPalette },
1241  { "QRadioButton", QPlatformTheme::RadioButtonPalette },
1242  { "QHeaderView", QPlatformTheme::HeaderPalette },
1243  { "QAbstractItemView", QPlatformTheme::ItemViewPalette },
1244  { "QMessageBoxLabel", QPlatformTheme::MessageBoxLabelPalette },
1245  { "QTabBar", QPlatformTheme::TabBarPalette },
1246  { "QLabel", QPlatformTheme::LabelPalette },
1247  { "QGroupBox", QPlatformTheme::GroupBoxPalette },
1248  { "QMenu", QPlatformTheme::MenuPalette },
1249  { "QMenuBar", QPlatformTheme::MenuBarPalette },
1250  { "QTextEdit", QPlatformTheme::TextEditPalette },
1251  { "QTextControl", QPlatformTheme::TextEditPalette },
1252  { "QLineEdit", QPlatformTheme::TextLineEditPalette },
1253  };
1254 
1255  for (const auto themedWidget : themedWidgets) {
1256  if (auto *palette = platformTheme->palette(themedWidget.palette))
1257  QApplication::setPalette(*palette, themedWidget.className);
1258  }
1259 }
1260 
1267 {
1268  return QGuiApplication::font();
1269 }
1270 
1282 {
1283  typedef FontHash::const_iterator FontHashConstIt;
1284 
1285  FontHash *hash = app_fonts();
1286 
1287  if (widget && hash && hash->size()) {
1288 #ifdef Q_OS_MAC
1289  // short circuit for small and mini controls
1291  return hash->value(QByteArrayLiteral("QSmallFont"));
1292  } else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
1293  return hash->value(QByteArrayLiteral("QMiniFont"));
1294  }
1295 #endif
1296  // Return the font for the nearest registered superclass
1297  const QMetaObject *metaObj = widget->metaObject();
1298  FontHashConstIt it = hash->constFind(metaObj->className());
1299  const FontHashConstIt cend = hash->constEnd();
1300  while (it == cend && metaObj != &QWidget::staticMetaObject) {
1301  metaObj = metaObj->superClass();
1302  it = hash->constFind(metaObj->className());
1303  }
1304  if (it != cend)
1305  return it.value();
1306  }
1307  return font();
1308 }
1309 
1318 {
1319  FontHash *hash = app_fonts();
1320  if (className && hash && hash->size()) {
1322  if (it != hash->constEnd())
1323  return *it;
1324  }
1325  return font();
1326 }
1327 
1328 
1348 void QApplication::setFont(const QFont &font, const char *className)
1349 {
1350  FontHash *hash = app_fonts();
1351  if (!className) {
1353  if (hash && hash->size())
1354  hash->clear();
1355  } else if (hash) {
1356  hash->insert(className, font);
1357  }
1358  if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
1361  for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) {
1362  QWidget *w = *it;
1363  if (!w->isWindow() && w->inherits(className)) // matching class
1364  sendEvent(w, &e);
1365  }
1366 
1367 #if QT_CONFIG(graphicsview)
1368  // Send to all scenes as well.
1369  QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
1371  it != scenes.constEnd(); ++it) {
1373  }
1374 #endif // QT_CONFIG(graphicsview)
1375  }
1379  else
1381  }
1382 }
1383 
1387 {
1388  if (!sys_font)
1389  sys_font = new QFont(font);
1390  else
1391  *sys_font = font;
1392 
1395 }
1396 
1400 {
1401 #if defined(QT_BUILD_INTERNAL)
1402  // Allow auto-tests to override the desktop style
1403  if (qEnvironmentVariableIsSet("QT_DESKTOP_STYLE_KEY"))
1404  return QString::fromLocal8Bit(qgetenv("QT_DESKTOP_STYLE_KEY"));
1405 #endif
1406 
1407  // The platform theme might return a style that is not available, find
1408  // first valid one.
1410  const QStringList availableKeys = QStyleFactory::keys();
1411  const auto styles = theme->themeHint(QPlatformTheme::StyleNames).toStringList();
1412  for (const QString &style : styles) {
1413  if (availableKeys.contains(style, Qt::CaseInsensitive))
1414  return style;
1415  }
1416  }
1417  return QString();
1418 }
1419 
1421 {
1425 
1426  // send to all top-level QWidgets
1427  for (auto *w : list) {
1428  windowList.removeOne(w->windowHandle());
1430  }
1431 
1432  // in case there are any plain QWindows in this QApplication-using
1433  // application, also send the notification to them
1434  for (int i = 0; i < windowList.size(); ++i)
1435  QCoreApplication::sendEvent(windowList.at(i), &ev);
1436 }
1437 
1451 {
1452  QWidgetList list;
1453  if (QWidgetPrivate::allWidgets != nullptr) {
1454  const auto isTopLevelWidget = [] (const QWidget *w) {
1455  return w->isWindow() && w->windowType() != Qt::Desktop;
1456  };
1458  std::back_inserter(list), isTopLevelWidget);
1459  }
1460  return list;
1461 }
1462 
1477 {
1480  return QWidgetList();
1481 }
1482 
1491 {
1493 }
1494 
1496 {
1497 #if QT_CONFIG(graphicsview)
1498  if (focus && focus->window()->graphicsProxyWidget())
1499  return;
1500 #endif
1501 
1502  hidden_focus_widget = nullptr;
1503 
1504  if (focus != focus_widget) {
1505  if (focus && focus->isHidden()) {
1507  return;
1508  }
1509 
1510  if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason)
1512  focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
1513  else if (focus && reason == Qt::ShortcutFocusReason) {
1514  focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
1515  }
1516  QWidget *prev = focus_widget;
1517  focus_widget = focus;
1518 
1519  if (focus_widget)
1520  focus_widget->d_func()->setFocus_sys();
1521 
1522  if (reason != Qt::NoFocusReason) {
1523 
1524  //send events
1525  if (prev) {
1526 #ifdef QT_KEYPAD_NAVIGATION
1527  if (QApplicationPrivate::keyboardNavigationEnabled()) {
1528  if (prev->hasEditFocus() && reason != Qt::PopupFocusReason)
1529  prev->setEditFocus(false);
1530  }
1531 #endif
1532  QFocusEvent out(QEvent::FocusOut, reason);
1533  QPointer<QWidget> that = prev;
1535  if (that)
1537  }
1539  QFocusEvent in(QEvent::FocusIn, reason);
1540  QPointer<QWidget> that = focus;
1542  if (that)
1544  }
1545  emit qApp->focusChanged(prev, focus_widget);
1546  }
1547  }
1548 }
1549 
1550 
1561 {
1563 }
1564 
1565 #if QT_DEPRECATED_SINCE(6,0)
1574 {
1576 }
1577 #endif
1578 
1579 bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows)
1580 {
1581  Q_ASSERT(processedWindows);
1583  if (!w->isVisible() || w->data->is_closing)
1584  break;
1585  QWindow *window = w->windowHandle();
1586  if (!window->close()) // Qt::WA_DeleteOnClose may cause deletion.
1587  return false;
1588  if (window)
1589  processedWindows->append(window);
1590  }
1591 
1592 retry:
1594  for (auto *w : list) {
1595  if (w->isVisible() && w->windowType() != Qt::Desktop &&
1596  !w->testAttribute(Qt::WA_DontShowOnScreen) && !w->data->is_closing) {
1597  QWindow *window = w->windowHandle();
1598  if (!window->close()) // Qt::WA_DeleteOnClose may cause deletion.
1599  return false;
1600  if (window)
1601  processedWindows->append(window);
1602  goto retry;
1603  }
1604  }
1605  return true;
1606 }
1607 
1625 {
1626  QWindowList processedWindows;
1627  QApplicationPrivate::tryCloseAllWidgetWindows(&processedWindows);
1628 }
1629 
1640 {
1641 #if QT_CONFIG(messagebox)
1643 #endif // QT_CONFIG(messagebox)
1644 }
1645 
1665 {
1666  Q_D(QApplication);
1667  if (e->type() == QEvent::Quit) {
1668  // FIXME: This logic first tries to close all windows, and then
1669  // checks whether it was successful, but the conditions used in
1670  // closeAllWindows() differ from the verification logic below.
1671  // We should build on the logic in tryCloseAllWidgetWindows().
1672  closeAllWindows();
1673  for (auto *w : topLevelWidgets()) {
1674  if (w->data->is_closing)
1675  continue;
1676  if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
1677  (!(w->windowType() == Qt::Dialog) || !w->parentWidget()) && !w->testAttribute(Qt::WA_DontShowOnScreen)) {
1678  e->ignore();
1679  return true;
1680  }
1681  }
1682  // Explicitly call QCoreApplication instead of QGuiApplication so that
1683  // we don't let QGuiApplication close any windows we skipped earlier in
1684  // closeAllWindows(). FIXME: Unify all this close magic through closeAllWindows.
1685  return QCoreApplication::event(e);
1686 #ifndef Q_OS_WIN
1687  } else if (e->type() == QEvent::LocaleChange) {
1688  // on Windows the event propagation is taken care by the
1689  // WM_SETTINGCHANGE event handler.
1690  const QWidgetList list = topLevelWidgets();
1691  for (auto *w : list) {
1692  if (!(w->windowType() == Qt::Desktop)) {
1693  if (!w->testAttribute(Qt::WA_SetLocale))
1694  w->d_func()->setLocale_helper(QLocale(), true);
1695  }
1696  }
1697 #endif
1698  } else if (e->type() == QEvent::Timer) {
1699  QTimerEvent *te = static_cast<QTimerEvent*>(e);
1700  Q_ASSERT(te != nullptr);
1701  if (te->timerId() == d->toolTipWakeUp.timerId()) {
1702  d->toolTipWakeUp.stop();
1703  if (d->toolTipWidget) {
1704  QWidget *w = d->toolTipWidget->window();
1705  // show tooltip if WA_AlwaysShowToolTips is set, or if
1706  // any ancestor of d->toolTipWidget is the active
1707  // window
1708  bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips);
1709  while (w && !showToolTip) {
1710  showToolTip = w->isActiveWindow();
1711  w = w->parentWidget();
1712  w = w ? w->window() : nullptr;
1713  }
1714  if (showToolTip) {
1715  QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
1716  QCoreApplication::sendEvent(d->toolTipWidget, &e);
1717  if (e.isAccepted()) {
1718  QStyle *s = d->toolTipWidget->style();
1719  int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, nullptr, d->toolTipWidget, nullptr);
1720  d->toolTipFallAsleep.start(sleepDelay, this);
1721  }
1722  }
1723  }
1724  } else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
1725  d->toolTipFallAsleep.stop();
1726  }
1727 #if QT_CONFIG(whatsthis)
1728  } else if (e->type() == QEvent::EnterWhatsThisMode) {
1730  return true;
1731 #endif
1732  }
1733 
1734  if (e->type() == QEvent::LanguageChange || e->type() == QEvent::ApplicationFontChange ||
1735  e->type() == QEvent::ApplicationPaletteChange) {
1736  // QGuiApplication::event does not account for the cases where
1737  // there is a top level widget without a window handle. So they
1738  // need to have the event posted here
1739  const QWidgetList list = topLevelWidgets();
1740  for (auto *w : list) {
1741  if (!w->windowHandle() && (w->windowType() != Qt::Desktop))
1742  postEvent(w, new QEvent(e->type()));
1743  }
1744  }
1745 
1746  return QGuiApplication::event(e);
1747 }
1748 
1749 // ### FIXME: topLevelWindows does not contain QWidgets without a parent
1750 // until QWidgetPrivate::create is called. So we have to override the
1751 // QGuiApplication::notifyLayoutDirectionChange
1752 // to do the right thing.
1754 {
1757 
1758  // send to all top-level QWidgets
1759  for (auto *w : list) {
1760  windowList.removeAll(w->windowHandle());
1763  }
1764 
1765  // in case there are any plain QWindows in this QApplication-using
1766  // application, also send the notification to them
1767  for (int i = 0; i < windowList.size(); ++i) {
1769  QCoreApplication::sendEvent(windowList.at(i), &ev);
1770  }
1771 }
1772 
1792 {
1793  QWidget* window = act?act->window():nullptr;
1794 
1796  return;
1797 
1798 #if QT_CONFIG(graphicsview)
1799  if (window && window->graphicsProxyWidget()) {
1800  // Activate the proxy's view->viewport() ?
1801  return;
1802  }
1803 #endif
1804 
1805  QWidgetList toBeActivated;
1806  QWidgetList toBeDeactivated;
1807 
1810  const QWidgetList list = topLevelWidgets();
1811  for (auto *w : list) {
1812  if (w->isVisible() && w->isActiveWindow())
1813  toBeDeactivated.append(w);
1814  }
1815  } else {
1816  toBeDeactivated.append(QApplicationPrivate::active_window);
1817  }
1818  }
1819 
1823 
1826  }
1827 
1829 
1832  const QWidgetList list = topLevelWidgets();
1833  for (auto *w : list) {
1834  if (w->isVisible() && w->isActiveWindow())
1835  toBeActivated.append(w);
1836  }
1837  } else {
1839  }
1840 
1841  }
1842 
1843  // first the activation/deactivation events
1844  QEvent activationChange(QEvent::ActivationChange);
1845  QEvent windowActivate(QEvent::WindowActivate);
1846  QEvent windowDeactivate(QEvent::WindowDeactivate);
1847 
1848  for (int i = 0; i < toBeActivated.size(); ++i) {
1849  QWidget *w = toBeActivated.at(i);
1850  sendSpontaneousEvent(w, &windowActivate);
1851  sendSpontaneousEvent(w, &activationChange);
1852  }
1853 
1854  for(int i = 0; i < toBeDeactivated.size(); ++i) {
1855  QWidget *w = toBeDeactivated.at(i);
1856  sendSpontaneousEvent(w, &windowDeactivate);
1857  sendSpontaneousEvent(w, &activationChange);
1858  }
1859 
1860  if (QApplicationPrivate::popupWidgets == nullptr) { // !inPopupMode()
1861  // then focus events
1866  if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
1868  else {
1870  if (w) {
1871  w->setFocus(Qt::ActiveWindowFocusReason);
1872  } else {
1874  if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus) {
1876  } else if (!QApplicationPrivate::active_window->isAncestorOf(w)) {
1877  // If the focus widget is not in the activate_window, clear the focus
1879  }
1880  }
1881  }
1882  }
1883  }
1884 }
1885 
1887 {
1888  // QTBUG-32177, wnd might be a QQuickView embedded via window container.
1889  while (wnd && !wnd->isTopLevel()) {
1890  QWindow *parent = wnd->parent();
1891  if (!parent)
1892  break;
1893 
1894  // Don't end up in windows not belonging to this application
1895  if (parent->handle() && parent->handle()->isForeignWindow())
1896  break;
1897 
1898  wnd = wnd->parent();
1899  }
1900  if (wnd) {
1901  const auto tlws = QApplication::topLevelWidgets();
1902  for (QWidget *tlw : tlws) {
1903  if (tlw->windowHandle() == wnd)
1904  return tlw;
1905  }
1906  }
1907  return nullptr;
1908 }
1909 
1911 {
1912 #ifndef Q_OS_MACOS
1913  // Some delayed focus event to ignore, unless we are on cocoa where
1914  // popups can be opened via right-click on inactive applications
1915  if (inPopupMode())
1916  return;
1917 #endif
1919  QWidget *focusWidget = qt_tlw_for_window(focusWindow);
1920  QApplication::setActiveWindow(focusWidget);
1921  // QTBUG-37126, Active X controls may set the focus on native child widgets.
1922  if (focusWindow && focusWidget && focusWindow != focusWidget->windowHandle()) {
1923  if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(focusWindow))
1924  if (QWidget *widget = widgetWindow->widget())
1925  if (widget->inherits("QAxHostWidget"))
1927  }
1928 
1929  // QApplication::setActiveWindow() will deliver window activation events for
1930  // QWidgetWindows. But for other subclasses of QWindow (like QQuickWindow), we
1931  // need to send them explicitly, like we do from the base class implementation.
1932  if (previous && !qobject_cast<QWidgetWindow *>(previous)) {
1934  QCoreApplication::sendEvent(previous, &de);
1935  }
1936 
1937  if (focusWindow && !qobject_cast<QWidgetWindow *>(focusWindow)) {
1939  QCoreApplication::sendEvent(focusWindow, &ae);
1940  }
1941 
1942  // don't call base class to avoid double delivery of WindowActivate/Deactivate events
1943 }
1944 
1951  bool *wrappingOccurred)
1952 {
1954 
1955  QWidget *f = toplevel->focusWidget();
1956  if (!f)
1957  f = toplevel;
1958 
1959  QWidget *w = f;
1960  QWidget *test = f->d_func()->focus_next;
1961  bool seenWindow = false;
1962  bool focusWidgetAfterWindow = false;
1963  while (test && test != f) {
1964  if (test->isWindow())
1965  seenWindow = true;
1966 
1967  // If the next focus widget has a focus proxy, we need to check to ensure
1968  // that the proxy is in the correct parent-child direction (according to
1969  // \a next). This is to ensure that we can tab in and out of compound widgets
1970  // without getting stuck in a tab-loop between parent and child.
1971  QWidget *focusProxy = test->d_func()->deepestFocusProxy();
1972  auto effectiveFocusPolicy = [](QWidget *widget) {
1973  return widget->isEnabled() ? widget->focusPolicy() : Qt::NoFocus;
1974  };
1975  const bool canTakeFocus = (effectiveFocusPolicy(focusProxy ? focusProxy : test)
1976  & focus_flag) == focus_flag;
1977  const bool composites = focusProxy ? (next ? focusProxy->isAncestorOf(test)
1978  : test->isAncestorOf(focusProxy))
1979  : false;
1980  if (canTakeFocus && !composites
1981  && test->isVisibleTo(toplevel) && test->isEnabled()
1982  && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
1983  && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))
1984  && f != focusProxy) {
1985  w = test;
1986  if (seenWindow)
1987  focusWidgetAfterWindow = true;
1988  if (next)
1989  break;
1990  }
1991  test = test->d_func()->focus_next;
1992  }
1993 
1994  if (wrappingOccurred != nullptr)
1995  *wrappingOccurred = next ? focusWidgetAfterWindow : !focusWidgetAfterWindow;
1996 
1997  if (w == f) {
1998  if (qt_in_tab_key_event) {
1999  w->window()->setAttribute(Qt::WA_KeyboardFocusChange);
2000  w->update();
2001  }
2002  return nullptr;
2003  }
2004  return w;
2005 }
2006 
2015 {
2016 #if 0
2017  if (leave) {
2020  }
2021  if (enter) {
2022  const QPoint windowPos = enter->window()->mapFromGlobal(globalPos);
2023  QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos);
2024  QCoreApplication::sendEvent(enter, & e);
2025  }
2026  return;
2027 #endif
2028 
2029  if ((!enter && !leave) || (enter == leave))
2030  return;
2031 #ifdef ALIEN_DEBUG
2032  qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave;
2033 #endif
2034  QWidgetList leaveList;
2035  QWidgetList enterList;
2036 
2037  bool sameWindow = leave && enter && leave->window() == enter->window();
2038  if (leave && !sameWindow) {
2039  auto *w = leave;
2040  do {
2041  leaveList.append(w);
2042  } while (!w->isWindow() && (w = w->parentWidget()));
2043  }
2044  if (enter && !sameWindow) {
2045  auto *w = enter;
2046  do {
2047  enterList.append(w);
2048  } while (!w->isWindow() && (w = w->parentWidget()));
2049  }
2050  if (sameWindow) {
2051  int enterDepth = 0;
2052  int leaveDepth = 0;
2053  auto *e = enter;
2054  while (!e->isWindow() && (e = e->parentWidget()))
2055  enterDepth++;
2056  auto *l = leave;
2057  while (!l->isWindow() && (l = l->parentWidget()))
2058  leaveDepth++;
2059  QWidget* wenter = enter;
2060  QWidget* wleave = leave;
2061  while (enterDepth > leaveDepth) {
2062  wenter = wenter->parentWidget();
2063  enterDepth--;
2064  }
2065  while (leaveDepth > enterDepth) {
2066  wleave = wleave->parentWidget();
2067  leaveDepth--;
2068  }
2069  while (!wenter->isWindow() && wenter != wleave) {
2070  wenter = wenter->parentWidget();
2071  wleave = wleave->parentWidget();
2072  }
2073 
2074  for (auto *w = leave; w != wleave; w = w->parentWidget())
2075  leaveList.append(w);
2076 
2077  for (auto *w = enter; w != wenter; w = w->parentWidget())
2078  enterList.append(w);
2079  }
2080 
2081  QEvent leaveEvent(QEvent::Leave);
2082  for (int i = 0; i < leaveList.size(); ++i) {
2083  auto *w = leaveList.at(i);
2085  QCoreApplication::sendEvent(w, &leaveEvent);
2086  if (w->testAttribute(Qt::WA_Hover) &&
2088  Q_ASSERT(instance());
2089  QHoverEvent he(QEvent::HoverLeave, QPointF(-1, -1), globalPosF, w->mapFromGlobal(globalPosF),
2091  qApp->d_func()->notify_helper(w, &he);
2092  }
2093  }
2094  }
2095  if (!enterList.isEmpty()) {
2096  // Guard against QGuiApplicationPrivate::lastCursorPosition initialized to qInf(), qInf().
2097  const QPointF globalPos = qIsInf(globalPosF.x())
2099  : globalPosF;
2100  const QPointF windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos);
2101  for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) {
2102  auto *w = *it;
2104  const QPointF localPos = w->mapFromGlobal(globalPos);
2105  QEnterEvent enterEvent(localPos, windowPos, globalPos);
2106  QCoreApplication::sendEvent(w, &enterEvent);
2107  if (w->testAttribute(Qt::WA_Hover) &&
2109  QHoverEvent he(QEvent::HoverEnter, localPos, QPointF(-1, -1), globalPos,
2111  qApp->d_func()->notify_helper(w, &he);
2112  }
2113  }
2114  }
2115  }
2116 
2117 #ifndef QT_NO_CURSOR
2118  // Update cursor for alien/graphics widgets.
2119 
2120  const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
2121  // Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor.
2122  // This is not required on Windows as the cursor is reset on every single mouse move.
2123  QWidget *parentOfLeavingCursor = nullptr;
2124  for (int i = 0; i < leaveList.size(); ++i) {
2125  auto *w = leaveList.at(i);
2126  if (!isAlien(w))
2127  break;
2128  if (w->testAttribute(Qt::WA_SetCursor)) {
2129  QWidget *parent = w->parentWidget();
2130  while (parent && parent->d_func()->data.in_destructor)
2131  parent = parent->parentWidget();
2132  parentOfLeavingCursor = parent;
2133  //continue looping, we need to find the downest alien widget with a cursor.
2134  // (downest on the screen)
2135  }
2136  }
2137  //check that we will not call qt_x11_enforce_cursor twice with the same native widget
2138  if (parentOfLeavingCursor && (!enterOnAlien
2139  || parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) {
2140 #if QT_CONFIG(graphicsview)
2141  if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
2142 #endif
2143  {
2144  if (enter == QApplicationPrivate::desktop()) {
2145  qt_qpa_set_cursor(enter, true);
2146  } else {
2147  qt_qpa_set_cursor(parentOfLeavingCursor, true);
2148  }
2149  }
2150  }
2151  if (enterOnAlien) {
2152  QWidget *cursorWidget = enter;
2153  while (!cursorWidget->isWindow() && !cursorWidget->isEnabled())
2154  cursorWidget = cursorWidget->parentWidget();
2155 
2156  if (!cursorWidget)
2157  return;
2158 
2159 #if QT_CONFIG(graphicsview)
2160  if (cursorWidget->window()->graphicsProxyWidget()) {
2161  QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor());
2162  } else
2163 #endif
2164  {
2165  qt_qpa_set_cursor(cursorWidget, true);
2166  }
2167  }
2168 #endif
2169 }
2170 
2171 /* exported for the benefit of testing tools */
2172 Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
2173 {
2175 }
2176 
2181 {
2182  widget = widget->window();
2184  return window && self->isWindowBlocked(window);
2185 }
2186 
2188 {
2189  QWindow *unused = nullptr;
2190  if (Q_UNLIKELY(!window)) {
2191  qWarning().nospace() << "window == 0 passed.";
2192  return false;
2193  }
2194  if (!blockingWindow)
2195  blockingWindow = &unused;
2196 
2197  if (modalWindowList.isEmpty()) {
2198  *blockingWindow = nullptr;
2199  return false;
2200  }
2201  QWidget *popupWidget = QApplication::activePopupWidget();
2202  QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : nullptr;
2203  if (popupWindow == window || (!popupWindow && QWindowPrivate::get(window)->isPopup())) {
2204  *blockingWindow = nullptr;
2205  return false;
2206  }
2207 
2208  for (int i = 0; i < modalWindowList.count(); ++i) {
2209  QWindow *modalWindow = modalWindowList.at(i);
2210 
2211  // A window is not blocked by another modal window if the two are
2212  // the same, or if the window is a child of the modal window.
2213  if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) {
2214  *blockingWindow = nullptr;
2215  return false;
2216  }
2217 
2218  Qt::WindowModality windowModality = modalWindow->modality();
2219  if (windowModality == Qt::NonModal) {
2220  // If modality type hasn't been set on the modalWindow's widget, as
2221  // when waiting for a native dialog, use ApplicationModal.
2222  windowModality = Qt::ApplicationModal;
2223  }
2224 
2225  switch (windowModality) {
2226  case Qt::ApplicationModal:
2227  if (modalWindow != window) {
2228  *blockingWindow = modalWindow;
2229  return true;
2230  }
2231  break;
2232  case Qt::WindowModal:
2233  {
2234  QWindow *w = window;
2235  do {
2236  QWindow *m = modalWindow;
2237  do {
2238  if (m == w) {
2239  *blockingWindow = m;
2240  return true;
2241  }
2242  QWindow *p = m->parent();
2243  if (!p)
2244  p = m->transientParent();
2245  m = p;
2246  } while (m);
2247  QWindow *p = w->parent();
2248  if (!p)
2249  p = w->transientParent();
2250  w = p;
2251  } while (w);
2252  break;
2253  }
2254  default:
2255  Q_ASSERT_X(false, "QApplication", "internal error, a modal window cannot be modeless");
2256  break;
2257  }
2258  }
2259  *blockingWindow = nullptr;
2260  return false;
2261 }
2262 
2269 {
2271  if (rettop)
2272  *rettop = top;
2273 
2274  // the active popup widget always gets the input event
2276  return true;
2277 
2278  return !isBlockedByModal(widget->window());
2279 }
2280 
2282 {
2283  QWidget * top = nullptr;
2284 
2286  return true;
2287 
2288  bool block_event = false;
2289 
2290  switch (type) {
2291  case QEvent::MouseButtonPress: // disallow mouse/key events
2293  case QEvent::MouseMove:
2294  case QEvent::KeyPress:
2295  case QEvent::KeyRelease:
2296  block_event = true;
2297  break;
2298  default:
2299  break;
2300  }
2301 
2302  if (block_event && top && top->parentWidget() == nullptr)
2303  top->raise();
2304 
2305  return !block_event;
2306 }
2307 
2309 {
2310  return !self->modalWindowList.isEmpty();
2311 }
2312 
2313 /*
2314  \internal
2315 */
2318  Qt::MouseButtons buttons, QWidget *buttonDown,
2319  QWidget *alienWidget)
2320 {
2321  Q_ASSERT(candidate);
2322 
2323  QWidget *mouseGrabber = QWidget::mouseGrabber();
2324  if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
2325  && !buttonDown && !mouseGrabber) {
2326  return nullptr;
2327  }
2328 
2329  if (alienWidget && alienWidget->internalWinId())
2330  alienWidget = nullptr;
2331 
2332  QWidget *receiver = candidate;
2333 
2334  if (!mouseGrabber)
2335  mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
2336 
2337  if (mouseGrabber && mouseGrabber != candidate) {
2338  receiver = mouseGrabber;
2339  *pos = receiver->mapFromGlobal(candidate->mapToGlobal(windowPos));
2340 #ifdef ALIEN_DEBUG
2341  qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos;
2342 #endif
2343  }
2344 
2345  return receiver;
2346 
2347 }
2348 
2349 /*
2350  \internal
2351 */
2353  QWidget *alienWidget, QWidget *nativeWidget,
2354  QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
2355  bool spontaneous, bool onlyDispatchEnterLeave)
2356 {
2357  Q_ASSERT(receiver);
2358  Q_ASSERT(event);
2359  Q_ASSERT(nativeWidget);
2360  Q_ASSERT(buttonDown);
2361 
2362  if (alienWidget && !isAlien(alienWidget))
2363  alienWidget = nullptr;
2364 
2365  QPointer<QWidget> receiverGuard = receiver;
2366  QPointer<QWidget> nativeGuard = nativeWidget;
2367  QPointer<QWidget> alienGuard = alienWidget;
2368  QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget();
2369 
2370  const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
2371 
2372  bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->position());
2373 
2374  // Clear the obsolete leaveAfterRelease value, if mouse button has been released but
2375  // leaveAfterRelease has not been updated.
2376  // This happens e.g. when modal dialog or popup is shown as a response to button click.
2377  if (leaveAfterRelease && !*buttonDown && !event->buttons())
2378  leaveAfterRelease = nullptr;
2379 
2380  if (*buttonDown) {
2381  if (!graphicsWidget) {
2382  // Register the widget that shall receive a leave event
2383  // after the last button is released.
2384  if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
2385  leaveAfterRelease = *buttonDown;
2386  if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
2387  *buttonDown = nullptr;
2388  }
2389  } else if (lastMouseReceiver && widgetUnderMouse) {
2390  // Dispatch enter/leave if we move:
2391  // 1) from an alien widget to another alien widget or
2392  // from a native widget to an alien widget (first OR case)
2393  // 2) from an alien widget to a native widget (second OR case)
2394  if ((alienWidget && alienWidget != lastMouseReceiver)
2395  || (isAlien(lastMouseReceiver) && !alienWidget)) {
2396  if (activePopupWidget) {
2397  if (!QWidget::mouseGrabber())
2398  dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->globalPosition());
2399  } else {
2400  dispatchEnterLeave(receiver, lastMouseReceiver, event->globalPosition());
2401  }
2402 
2403  }
2404  }
2405 
2406 #ifdef ALIEN_DEBUG
2407  qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
2408  << "pos:" << event->position() << "alien" << alienWidget << "button down"
2409  << *buttonDown << "last" << lastMouseReceiver << "leave after release"
2410  << leaveAfterRelease;
2411 #endif
2412 
2413  // We need this quard in case someone opens a modal dialog / popup. If that's the case
2414  // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
2415  const bool wasLeaveAfterRelease = leaveAfterRelease != nullptr;
2416  bool result = true;
2417  // This code is used for sending the synthetic enter/leave events for cases where it is needed
2418  // due to other events causing the widget under the mouse to change. However in those cases
2419  // we do not want to send the mouse event associated with this call, so this enables us to
2420  // not send the unneeded mouse event
2421  if (!onlyDispatchEnterLeave) {
2422  if (spontaneous)
2423  result = QApplication::sendSpontaneousEvent(receiver, event);
2424  else
2426  }
2427 
2428  if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
2429  && !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) {
2430  // Dispatch enter/leave if:
2431  // 1) the mouse grabber is an alien widget
2432  // 2) the button is released on an alien widget
2433  QWidget *enter = nullptr;
2434  if (nativeGuard)
2435  enter = alienGuard ? alienWidget : nativeWidget;
2436  else // The receiver is typically deleted on mouse release with drag'n'drop.
2437  enter = QApplication::widgetAt(event->globalPosition().toPoint());
2438  dispatchEnterLeave(enter, leaveAfterRelease, event->globalPosition());
2439  leaveAfterRelease = nullptr;
2440  lastMouseReceiver = enter;
2441  } else if (!wasLeaveAfterRelease) {
2442  if (activePopupWidget) {
2443  if (!QWidget::mouseGrabber())
2444  lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr);
2445  } else {
2446  lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPosition().toPoint());
2447  }
2448  }
2449 
2450  return result;
2451 }
2452 
2453 /*
2454  This function should only be called when the widget changes visibility, i.e.
2455  when the \a widget is shown, hidden or deleted. This function does nothing
2456  if the widget is a top-level or native, i.e. not an alien widget. In that
2457  case enter/leave events are generated by the underlying windowing system.
2458 */
2460 extern Q_WIDGETS_EXPORT QWidget *qt_button_down;
2462 {
2463 #ifndef QT_NO_CURSOR
2464  if (!widget || widget->isWindow())
2465  return;
2466  const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
2467  if (!widgetInShow && widget != qt_last_mouse_receiver)
2468  return; // Widget was not under the cursor when it was hidden/deleted.
2469 
2470  if (widgetInShow && widget->parentWidget()->data->in_show)
2471  return; // Ignore recursive show.
2472 
2473  QWidget *mouseGrabber = QWidget::mouseGrabber();
2474  if (mouseGrabber && mouseGrabber != widget)
2475  return; // Someone else has the grab; enter/leave should not occur.
2476 
2477  QWidget *tlw = widget->window();
2478  if (tlw->data->in_destructor || tlw->data->is_closing)
2479  return; // Closing down the business.
2480 
2481  if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw))
2482  return; // Mouse cursor not inside the widget's top-level.
2483 
2484  const QPoint globalPos(QCursor::pos());
2485  QPoint windowPos = tlw->mapFromGlobal(globalPos);
2486 
2487  // Find the current widget under the mouse. If this function was called from
2488  // the widget's destructor, we have to make sure childAt() doesn't take into
2489  // account widgets that are about to be destructed.
2490  QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(windowPos, widget->data->in_destructor);
2491  if (!widgetUnderCursor)
2492  widgetUnderCursor = tlw;
2493  QPoint pos = widgetUnderCursor->mapFrom(tlw, windowPos);
2494 
2495  if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor))
2496  return; // Mouse cursor not inside the widget or any of its children.
2497 
2498  if (widget->data->in_destructor && qt_button_down == widget)
2499  qt_button_down = nullptr;
2500 
2501  // A mouse move is not actually sent, but we utilize the sendMouseEvent() call to send the
2502  // enter/leave events as appropriate
2504  sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver, true, true);
2505 #else // !QT_NO_CURSOR
2506  Q_UNUSED(widget);
2507 #endif // QT_NO_CURSOR
2508 }
2509 
2519 {
2520  CHECK_QAPP_INSTANCE(nullptr)
2521  if (!qt_desktopWidget || // not created yet
2522  !(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
2523  qt_desktopWidget = new QWidget(nullptr, Qt::Desktop);
2524  }
2525  return qt_desktopWidget;
2526 }
2527 
2528 /*
2529  Sets the time after which a drag should start to \a ms ms.
2530 
2531  \sa startDragTime()
2532 */
2533 
2535 {
2537 }
2538 
2557 {
2559 }
2560 
2561 /*
2562  Sets the distance after which a drag should start to \a l pixels.
2563 
2564  \sa startDragDistance()
2565 */
2566 
2568 {
2570 }
2571 
2596 {
2598 }
2599 
2630 {
2631  return QGuiApplication::exec();
2632 }
2633 
2637 {
2638  Q_D(QApplication);
2639  // no events are delivered after ~QCoreApplication() has started
2640  if (QApplicationPrivate::is_app_closing)
2641  return true;
2642 
2643  if (Q_UNLIKELY(!receiver)) { // serious error
2644  qWarning("QApplication::notify: Unexpected null receiver");
2645  return true;
2646  }
2647 
2648 #ifndef QT_NO_DEBUG
2650 #endif
2651 
2652  const bool isWindowType = receiver->isWindowType();
2653  const bool isWidgetType = receiver->isWidgetType();
2654  if (isWindowType
2656  return true; // Platform plugin ate the event
2657  }
2658 
2660 
2661 #ifndef QT_NO_GESTURES
2662  // walk through parents and check for gestures
2663  if (d->gestureManager) {
2664  switch (e->type()) {
2665  case QEvent::Paint:
2666  case QEvent::MetaCall:
2671  case QEvent::ChildRemoved:
2672  case QEvent::UpdateRequest:
2673  case QEvent::UpdateLater:
2674  case QEvent::LocaleChange:
2675  case QEvent::Style:
2676  case QEvent::IconDrag:
2677  case QEvent::StyleChange:
2684  break;
2685  default:
2686  if (d->gestureManager->thread() == QThread::currentThread()) {
2687  if (isWidgetType) {
2688  if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
2689  return true;
2690  } else {
2691  // a special case for events that go to QGesture objects.
2692  // We pass the object to the gesture manager and it'll figure
2693  // out if it's QGesture or not.
2694  if (d->gestureManager->filterEvent(receiver, e))
2695  return true;
2696  }
2697  }
2698  break;
2699  }
2700  }
2701 #endif // QT_NO_GESTURES
2702 
2703  switch (e->type()) {
2706  // Close all popups (triggers when switching applications
2707  // by pressing ALT-TAB on Windows, which is not receive as key event.
2708  // triggers when the screen rotates.)
2709  d->closeAllPopups();
2710  break;
2711  case QEvent::Wheel: // User input and window activation makes tooltips sleep
2713  case QEvent::KeyPress:
2714  case QEvent::KeyRelease:
2715  case QEvent::FocusOut:
2716  case QEvent::FocusIn:
2720  d->toolTipFallAsleep.stop();
2721  Q_FALLTHROUGH();
2722  case QEvent::Leave:
2723  d->toolTipWakeUp.stop();
2724  default:
2725  break;
2726  }
2727 
2728  switch (e->type()) {
2729  case QEvent::KeyPress: {
2730  QKeyEvent* keyEvent = static_cast<QKeyEvent*>(e);
2731  const int key = keyEvent->key();
2732  // When a key press is received which is not spontaneous then it needs to
2733  // be manually sent as a shortcut override event to ensure that any
2734  // matching shortcut is triggered first. This enables emulation/playback
2735  // of recorded events to still have the same effect.
2736  if (!e->spontaneous() && isWidgetType
2737  && qt_sendShortcutOverrideEvent(static_cast<QWidget *>(receiver), keyEvent->timestamp(),
2738  key, keyEvent->modifiers(), keyEvent->text(),
2739  keyEvent->isAutoRepeat(), keyEvent->count())) {
2740  return true;
2741  }
2743  || key == Qt::Key_Tab
2744  || key == Qt::Key_Left
2745  || key == Qt::Key_Up
2746  || key == Qt::Key_Right
2747  || key == Qt::Key_Down);
2748  }
2749  default:
2750  break;
2751  }
2752 
2753  bool res = false;
2754  if (isWidgetType) {
2755  QWidget * w = static_cast<QWidget *>(receiver);
2756  switch (e->type()) {
2758  case QEvent::KeyPress:
2759  case QEvent::KeyRelease: {
2760  QKeyEvent* key = static_cast<QKeyEvent*>(e);
2761  bool def = key->isAccepted();
2762  /*
2763  QLineEdit will emit a signal on Key_Return, but
2764  ignore the event, and sometimes the connected
2765  slot deletes the QLineEdit (common in itemview
2766  delegates), so we have to check if the widget
2767  was destroyed even if the event was ignored (to
2768  prevent a crash)
2769 
2770  Note that we don't have to reset pr while
2771  propagating (because the original receiver will
2772  be destroyed if one of its ancestors is)
2773  */
2774  QPointer<QObject> pr = receiver;
2775  while (w) {
2776  if (def)
2777  key->accept();
2778  else
2779  key->ignore();
2780  res = d->notify_helper(w, e);
2781 
2782  if (res && key->isAccepted())
2783  break;
2784  if (!pr || w->isWindow())
2785  break;
2786 
2787  w = w->parentWidget();
2788  }
2789  qt_in_tab_key_event = false;
2790  break;
2791  }
2795  case QEvent::MouseMove: {
2796  QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
2797  QPoint relpos = mouse->position().toPoint();
2798 
2799  if (e->spontaneous()) {
2800  if (e->type() != QEvent::MouseMove)
2801  QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
2802 
2803  // ### Qt 7 These dynamic tool tips should be an OPT-IN feature. Some platforms
2804  // like macOS (probably others too), can optimize their views by not
2805  // dispatching mouse move events. We have attributes to control hover,
2806  // and mouse tracking, but as long as we are deciding to implement this
2807  // feature without choice of opting-in or out, you ALWAYS have to have
2808  // tracking enabled. Therefore, the other properties give a false sense of
2809  // performance enhancement.
2810  if (e->type() == QEvent::MouseMove && mouse->buttons() == 0
2811  && w->rect().contains(relpos)) { // Outside due to mouse grab?
2812  d->toolTipWidget = w;
2813  d->toolTipPos = relpos;
2814  d->toolTipGlobalPos = mouse->globalPosition().toPoint();
2815  QStyle *s = d->toolTipWidget->style();
2816  int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr);
2817  d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this);
2818  }
2819  }
2820 
2821  bool eventAccepted = mouse->isAccepted();
2822 
2823  QPointer<QWidget> pw = w;
2824  while (w) {
2825  QMouseEvent me(mouse->type(), relpos, mouse->scenePosition(), mouse->globalPosition().toPoint(),
2826  mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source(),
2827  mouse->pointingDevice());
2828  me.m_spont = mouse->spontaneous();
2829  me.setTimestamp(mouse->timestamp());
2831  // throw away any mouse-tracking-only mouse events
2832  if (!w->hasMouseTracking()
2833  && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
2834  // but still send them through all application event filters (normally done by notify_helper)
2835  d->sendThroughApplicationEventFilters(w, w == receiver ? mouse : &me);
2836  res = true;
2837  } else {
2838  w->setAttribute(Qt::WA_NoMouseReplay, false);
2839  res = d->notify_helper(w, w == receiver ? mouse : &me);
2840  e->m_spont = false;
2841  }
2842  eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
2843  if (res && eventAccepted)
2844  break;
2845  if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
2846  break;
2847  relpos += w->pos();
2848  w = w->parentWidget();
2849  }
2850 
2851  mouse->setAccepted(eventAccepted);
2852 
2853  if (e->type() == QEvent::MouseMove) {
2854  if (!pw)
2855  break;
2856 
2857  w = static_cast<QWidget *>(receiver);
2858  relpos = mouse->position().toPoint();
2859  QPoint diff = relpos - w->mapFromGlobal(mouse->globalPosition().toPoint());
2860  while (w) {
2861  if (w->testAttribute(Qt::WA_Hover) &&
2863  QHoverEvent he(QEvent::HoverMove, relpos, mouse->globalPosition(), relpos - diff, mouse->modifiers());
2864  d->notify_helper(w, &he);
2865  }
2866  if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
2867  break;
2868  relpos += w->pos();
2869  w = w->parentWidget();
2870  }
2871  }
2872 
2873  d->hoverGlobalPos = mouse->globalPosition().toPoint();
2874  break;
2875  }
2876 #if QT_CONFIG(wheelevent)
2877  case QEvent::Wheel: {
2878  // QTBUG-40656, QTBUG-42731: ignore wheel events when a popup (QComboBox) is open.
2879  if (const QWidget *popup = QApplication::activePopupWidget()) {
2880  if (w->window() != popup)
2881  return true;
2882  }
2883 
2884  QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
2885  if (!wheel->spontaneous()) {
2886  /*
2887  Synthesized events shouldn't propagate, e.g. QScrollArea passes events from the
2888  viewport on to the scrollbars, which might ignore the event if there is no more
2889  space to scroll. If we would propagate, the event would come back to the viewport.
2890  */
2891  res = d->notify_helper(w, wheel);
2892  break;
2893  }
2894 
2895  const Qt::ScrollPhase phase = wheel->phase();
2896  QPoint relpos = wheel->position().toPoint();
2897 
2898  // Ideally, we should lock on a widget when it starts receiving wheel
2899  // events. This avoids other widgets to start receiving those events
2900  // as the mouse cursor hovers them. However, given the way common
2901  // wheeled mice work, there's no certain way of connecting different
2902  // wheel events as a stream. This results in the NoScrollPhase case,
2903  // where we just send the event from the original receiver and up its
2904  // hierarchy until the event gets accepted.
2905  //
2906  // In the case of more evolved input devices, like Apple's trackpad or
2907  // Magic Mouse, we receive the scroll phase information. This helps us
2908  // connect wheel events as a stream and therefore makes it easier to
2909  // lock on the widget onto which the scrolling was initiated.
2910  //
2911  // We assume that, when supported, the phase cycle follows the pattern:
2912  //
2913  // ScrollBegin (ScrollUpdate* ScrollMomentum* ScrollEnd)+
2914  //
2915  // This means that we can have scrolling sequences (starting with ScrollBegin)
2916  // or partial sequences (after a ScrollEnd and starting with ScrollUpdate).
2917 
2918  // a widget has already grabbed the wheel for a sequence
2919  if (QApplicationPrivate::wheel_widget) {
2920  Q_ASSERT(phase != Qt::NoScrollPhase);
2921  w = QApplicationPrivate::wheel_widget;
2922  relpos = w->mapFromGlobal(wheel->globalPosition().toPoint());
2923  }
2924  /*
2925  Start or finish a scrolling sequence by grabbing/releasing the wheel via
2926  wheel_widget. The sequence might be partial (ie. not start with ScrollBegin),
2927  e.g. if the previous wheel_widget was destroyed mid-sequence.
2928  */
2929  switch (phase) {
2930  case Qt::ScrollEnd:
2931  QApplicationPrivate::wheel_widget = nullptr;
2932  break;
2933  case Qt::ScrollBegin:
2934  QApplicationPrivate::wheel_widget = w;
2935  Q_FALLTHROUGH();
2936  case Qt::ScrollUpdate:
2937  case Qt::ScrollMomentum:
2938  if (!QApplicationPrivate::wheel_widget)
2939  QApplicationPrivate::wheel_widget = w;
2940  Q_FALLTHROUGH();
2941  case Qt::NoScrollPhase:
2942  QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
2943  break;
2944  // no default: - we want warnings if we don't handle all phases explicitly
2945  }
2946 
2947  QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(),
2948  wheel->modifiers(), phase, wheel->inverted(), wheel->source(), wheel->pointingDevice());
2949 
2950  we.setTimestamp(wheel->timestamp());
2951  bool eventAccepted;
2952  do {
2953  // events are delivered as accepted and ignored by the default event handler
2954  // since we always send the same QWheelEvent object, we need to reset the accepted state
2955  we.setAccepted(true);
2956  we.m_spont = wheel->spontaneous() && w == receiver;
2957  res = d->notify_helper(w, &we);
2958  eventAccepted = we.isAccepted();
2959  if (res && eventAccepted)
2960  break;
2961  if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
2962  break;
2963 
2964  QMutableEventPoint::setPosition(we.point(0), we.position() + w->pos());
2965  w = w->parentWidget();
2966  } while (w);
2967  wheel->setAccepted(eventAccepted);
2968  break;
2969  }
2970 #endif
2971 #ifndef QT_NO_CONTEXTMENU
2972  case QEvent::ContextMenu: {
2973  QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
2974  QPoint relpos = context->pos();
2975  bool eventAccepted = context->isAccepted();
2976  while (w) {
2977  QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
2978  ce.m_spont = e->spontaneous();
2979  res = d->notify_helper(w, w == receiver ? context : &ce);
2980  eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
2981  e->m_spont = false;
2982 
2983  if (res && eventAccepted)
2984  break;
2985  if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
2986  break;
2987 
2988  relpos += w->pos();
2989  w = w->parentWidget();
2990  }
2991  context->setAccepted(eventAccepted);
2992  break;
2993  }
2994 #endif // QT_NO_CONTEXTMENU
2995 #if QT_CONFIG(tabletevent)
2996  case QEvent::TabletMove:
2997  case QEvent::TabletPress:
2998  case QEvent::TabletRelease: {
2999  QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
3000  QPointF relpos = tablet->position();
3001  bool eventAccepted = tablet->isAccepted();
3002  while (w) {
3003  QTabletEvent te(tablet->type(), tablet->pointingDevice(), relpos, tablet->globalPosition(),
3004  tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
3005  tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
3006  tablet->modifiers(), tablet->button(), tablet->buttons());
3007  te.m_spont = e->spontaneous();
3008  te.setAccepted(false);
3009  res = d->notify_helper(w, w == receiver ? tablet : &te);
3010  eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
3011  e->m_spont = false;
3012  if (res && eventAccepted)
3013  break;
3014  if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
3015  break;
3016 
3017  relpos += w->pos();
3018  w = w->parentWidget();
3019  }
3020  tablet->setAccepted(eventAccepted);
3021  break;
3022  }
3023 #endif // QT_CONFIG(tabletevent)
3024 
3025 #if QT_CONFIG(tooltip) || QT_CONFIG(whatsthis)
3026  case QEvent::ToolTip:
3027  case QEvent::WhatsThis:
3028  case QEvent::QueryWhatsThis: {
3029  QHelpEvent *help = static_cast<QHelpEvent*>(e);
3030  QPoint relpos = help->pos();
3031  bool eventAccepted = help->isAccepted();
3032  while (w) {
3033  QHelpEvent he(help->type(), relpos, help->globalPos());
3034  he.m_spont = e->spontaneous();
3035  res = d->notify_helper(w, w == receiver ? help : &he);
3036  e->m_spont = false;
3037  eventAccepted = (w == receiver ? help : &he)->isAccepted();
3038  if (res && eventAccepted)
3039  break;
3040  if (w->isWindow())
3041  break;
3042 
3043  relpos += w->pos();
3044  w = w->parentWidget();
3045  }
3046  help->setAccepted(eventAccepted);
3047  break;
3048  }
3049 #endif
3050 #if QT_CONFIG(statustip) || QT_CONFIG(whatsthis)
3051  case QEvent::StatusTip:
3053  while (w) {
3054  res = d->notify_helper(w, e);
3055  if (res && e->isAccepted())
3056  break;
3057  if (w->isWindow())
3058  break;
3059  w = w->parentWidget();
3060  }
3061  break;
3062 #endif
3063 
3064 #if QT_CONFIG(draganddrop)
3065  case QEvent::DragEnter: {
3066  QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
3067 #if QT_CONFIG(graphicsview)
3068  // QGraphicsProxyWidget handles its own propagation,
3069  // and we must not change QDragManagers currentTarget.
3070  const auto &extra = w->window()->d_func()->extra;
3071  if (extra && extra->proxyWidget) {
3072  res = d->notify_helper(w, dragEvent);
3073  break;
3074  }
3075 #endif
3076  while (w) {
3077  if (w->isEnabled() && w->acceptDrops()) {
3078  res = d->notify_helper(w, dragEvent);
3079  if (res && dragEvent->isAccepted()) {
3081  break;
3082  }
3083  }
3084  if (w->isWindow())
3085  break;
3086  dragEvent->m_pos = w->mapToParent(dragEvent->m_pos);
3087  w = w->parentWidget();
3088  }
3089  break;
3090  }
3091  case QEvent::DragMove:
3092  case QEvent::Drop:
3093  case QEvent::DragLeave: {
3094 #if QT_CONFIG(graphicsview)
3095  // QGraphicsProxyWidget handles its own propagation,
3096  // and we must not change QDragManagers currentTarget.
3097  const auto &extra = w->window()->d_func()->extra;
3098  bool isProxyWidget = extra && extra->proxyWidget;
3099  if (!isProxyWidget)
3100 #endif
3101  w = qobject_cast<QWidget *>(QDragManager::self()->currentTarget());
3102 
3103  if (!w)
3104  break;
3105  if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
3106  QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
3107  QWidget *origReceiver = static_cast<QWidget *>(receiver);
3108  while (origReceiver && w != origReceiver) {
3109  dragEvent->m_pos = origReceiver->mapToParent(dragEvent->m_pos);
3110  origReceiver = origReceiver->parentWidget();
3111  }
3112  }
3113  res = d->notify_helper(w, e);
3114  if (e->type() != QEvent::DragMove
3115 #if QT_CONFIG(graphicsview)
3116  && !isProxyWidget
3117 #endif
3118  )
3119  QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop);
3120  break;
3121 #endif
3122  }
3123  case QEvent::TouchBegin: {
3124  // Note: TouchUpdate and TouchEnd events are never propagated
3126  bool eventAccepted = touchEvent->isAccepted();
3127  bool acceptTouchEvents = w->testAttribute(Qt::WA_AcceptTouchEvents);
3128 
3129  if (acceptTouchEvents && e->spontaneous()) {
3130  const QPoint localPos = touchEvent->points()[0].position().toPoint();
3131  QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, localPos);
3132  }
3133 
3134 #ifndef QT_NO_GESTURES
3135  QPointer<QWidget> gesturePendingWidget;
3136 #endif
3137 
3138  while (w) {
3139  // first, try to deliver the touch event
3140  acceptTouchEvents = w->testAttribute(Qt::WA_AcceptTouchEvents);
3141  touchEvent->setTarget(w);
3142  touchEvent->setAccepted(acceptTouchEvents);
3143  QPointer<QWidget> p = w;
3144  res = acceptTouchEvents && d->notify_helper(w, touchEvent);
3145  eventAccepted = touchEvent->isAccepted();
3146  if (p.isNull()) {
3147  // widget was deleted
3148  w = nullptr;
3149  } else {
3150  w->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
3151  }
3152  touchEvent->m_spont = false;
3153  if (res && eventAccepted) {
3154  // the first widget to accept the TouchBegin gets an implicit grab.
3155  d->activateImplicitTouchGrab(w, touchEvent);
3156  break;
3157  }
3158 #ifndef QT_NO_GESTURES
3159  if (gesturePendingWidget.isNull() && w && QGestureManager::gesturePending(w))
3160  gesturePendingWidget = w;
3161 #endif
3162  if (!w || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
3163  break;
3164 
3165  const QPoint offset = w->pos();
3166  w = w->parentWidget();
3167  touchEvent->setTarget(w);
3168  for (int i = 0; i < touchEvent->pointCount(); ++i) {
3169  auto &pt = touchEvent->point(i);
3170  QMutableEventPoint::setPosition(pt, pt.position() + offset);
3171  }
3172  }
3173 
3174 #ifndef QT_NO_GESTURES
3175  if (!eventAccepted && !gesturePendingWidget.isNull()) {
3176  // the first widget subscribed to a gesture gets an implicit grab for all
3177  // points, also for events and event points that have not been accepted.
3178  d->activateImplicitTouchGrab(gesturePendingWidget, touchEvent, QApplicationPrivate::GrabAllPoints);
3179  }
3180 #endif
3181 
3182  touchEvent->setAccepted(eventAccepted);
3183  break;
3184  }
3185  case QEvent::TouchUpdate:
3186  case QEvent::TouchEnd:
3187  // We may get here if the widget is subscribed to a gesture,
3188  // but has not accepted TouchBegin. Propagate touch events
3189  // only if TouchBegin has been accepted.
3190  if (w->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent))
3191  res = d->notify_helper(w, e);
3192  break;
3194  inputMethod()->show();
3195  break;
3197  inputMethod()->hide();
3198  break;
3199 
3200 #ifndef QT_NO_GESTURES
3201  case QEvent::NativeGesture:
3202  while (w) {
3203  e->ignore();
3204  res = d->notify_helper(w, e);
3205  if (res && e->isAccepted())
3206  break;
3207  if (w->isWindow())
3208  break;
3209  w = w->parentWidget();
3210  }
3211  break;
3212  case QEvent::Gesture:
3213  case QEvent::GestureOverride: {
3214  QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
3215  QList<QGesture *> allGestures = gestureEvent->gestures();
3216 
3217  bool eventAccepted = gestureEvent->isAccepted();
3218  bool wasAccepted = eventAccepted;
3219  while (w) {
3220  // send only gestures the widget expects
3221  QList<QGesture *> gestures;
3222  QWidgetPrivate *wd = w->d_func();
3223  for (int i = 0; i < allGestures.size();) {
3224  QGesture *g = allGestures.at(i);
3227  wd->gestureContext.find(type);
3228  bool deliver = contextit != wd->gestureContext.end() &&
3229  (g->state() == Qt::GestureStarted || w == receiver ||
3230  (contextit.value() & Qt::ReceivePartialGestures));
3231  if (deliver) {
3232  allGestures.removeAt(i);
3233  gestures.append(g);
3234  } else {
3235  ++i;
3236  }
3237  }
3238  if (!gestures.isEmpty()) { // we have gestures for this w
3239  QGestureEvent ge(gestures);
3240  ge.t = gestureEvent->t;
3241  ge.m_spont = gestureEvent->spontaneous();
3242  ge.m_accept = wasAccepted;
3243  ge.m_accepted = gestureEvent->m_accepted;
3244  res = d->notify_helper(w, &ge);
3245  gestureEvent->m_spont = false;
3246  eventAccepted = ge.isAccepted();
3247  for (int i = 0; i < gestures.size(); ++i) {
3248  QGesture *g = gestures.at(i);
3249  // Ignore res [event return value] because handling of multiple gestures
3250  // packed into a single QEvent depends on not consuming the event
3251  if (eventAccepted || ge.isAccepted(g)) {
3252  // if the gesture was accepted, mark the target widget for it
3253  gestureEvent->m_targetWidgets[g->gestureType()] = w;
3254  gestureEvent->setAccepted(g, true);
3255  } else {
3256  // if the gesture was explicitly ignored by the application,
3257  // put it back so a parent can get it
3258  allGestures.append(g);
3259  }
3260  }
3261  }
3262  if (allGestures.isEmpty()) // everything delivered
3263  break;
3264  if (w->isWindow())
3265  break;
3266  w = w->parentWidget();
3267  }
3268  for (QGesture *g : qAsConst(allGestures))
3269  gestureEvent->setAccepted(g, false);
3270  gestureEvent->m_accept = false; // to make sure we check individual gestures
3271  break;
3272  }
3273 #endif // QT_NO_GESTURES
3274 #ifdef Q_OS_MAC
3275  // Enable touch events on enter, disable on leave.
3276  typedef void (*RegisterTouchWindowFn)(QWindow *, bool);
3277  case QEvent::Enter:
3278  if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
3279  RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
3281  if (registerTouchWindow)
3282  registerTouchWindow(w->window()->windowHandle(), true);
3283  }
3284  res = d->notify_helper(receiver, e);
3285  break;
3286  case QEvent::Leave:
3287  if (w->testAttribute(Qt::WA_AcceptTouchEvents)) {
3288  RegisterTouchWindowFn registerTouchWindow = reinterpret_cast<RegisterTouchWindowFn>
3290  if (registerTouchWindow)
3291  registerTouchWindow(w->window()->windowHandle(), false);
3292  }
3293  res = d->notify_helper(receiver, e);
3294  break;
3295 #endif
3296  default:
3297  res = d->notify_helper(receiver, e);
3298  break;
3299  }
3300  } else {
3301  res = d->notify_helper(receiver, e);
3302  }
3303 
3304  return res;
3305 }
3306 
3308 {
3309  // These tracepoints (and the whole function, actually) are very similar
3310  // to the ones in QCoreApplicationPrivate::notify_helper; the reason for their
3311  // duplication is because tracepoint symbols are not exported by QtCore.
3312  // If you adjust the tracepoints here, consider adjusting QCoreApplicationPrivate too.
3313  Q_TRACE(QApplication_notify_entry, receiver, e, e->type());
3314  bool consumed = false;
3315  bool filtered = false;
3316  Q_TRACE_EXIT(QApplication_notify_exit, consumed, filtered);
3317 
3318  // send to all application event filters
3319  if (threadRequiresCoreApplication()
3320  && receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread()
3321  && sendThroughApplicationEventFilters(receiver, e)) {
3322  filtered = true;
3323  return filtered;
3324  }
3325 
3326  if (receiver->isWidgetType()) {
3327  QWidget *widget = static_cast<QWidget *>(receiver);
3328 
3329 #if !defined(QT_NO_CURSOR)
3330  // toggle HasMouse widget state on enter and leave
3331  if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
3334  else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
3336 #endif
3337 
3338  if (QLayout *layout=widget->d_func()->layout) {
3339  layout->widgetEvent(e);
3340  }
3341  }
3342 
3343  // send to all receiver event filters
3344  if (sendThroughObjectEventFilters(receiver, e)) {
3345  filtered = true;
3346  return filtered;
3347  }
3348 
3349  // deliver the event
3350  consumed = receiver->event(e);
3351 
3353  return consumed;
3354 }
3355 
3357 {
3358  return QApplicationPrivate::popupWidgets != nullptr;
3359 }
3360 
3361 static void ungrabKeyboardForPopup(QWidget *popup)
3362 {
3365  else
3366  qt_widget_private(popup)->stealKeyboardGrab(false);
3367 }
3368 
3369 static void ungrabMouseForPopup(QWidget *popup)
3370 {
3371  if (QWidget::mouseGrabber())
3373  else
3374  qt_widget_private(popup)->stealMouseGrab(false);
3375 }
3376 
3377 static bool popupGrabOk;
3378 
3379 static void grabForPopup(QWidget *popup)
3380 {
3382  popupGrabOk = qt_widget_private(popup)->stealKeyboardGrab(true);
3383  if (popupGrabOk) {
3384  popupGrabOk = qt_widget_private(popup)->stealMouseGrab(true);
3385  if (!popupGrabOk) {
3386  // transfer grab back to the keyboard grabber if any
3387  ungrabKeyboardForPopup(popup);
3388  }
3389  }
3390 }
3391 
3392 extern QWidget *qt_popup_down;
3393 extern bool qt_replay_popup_mouse_event;
3394 extern bool qt_popup_down_closed;
3395 
3397 {
3398  // Close all popups: In case some popup refuses to close,
3399  // we give up after 1024 attempts (to avoid an infinite loop).
3400  int maxiter = 1024;
3401  QWidget *popup;
3402  while ((popup = QApplication::activePopupWidget()) && maxiter--)
3403  popup->close(); // this will call QApplicationPrivate::closePopup
3404  return true;
3405 }
3406 
3408 {
3409  if (!popupWidgets)
3410  return;
3411  popupWidgets->removeAll(popup);
3412 
3413  if (popup == qt_popup_down) {
3414  qt_button_down = nullptr;
3415  qt_popup_down_closed = true;
3416  qt_popup_down = nullptr;
3417  }
3418 
3419  if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
3422  qt_popup_down_closed = false;
3423 
3424  if (popupGrabOk) {
3425  popupGrabOk = false;
3426 
3427  // TODO on multi-seat window systems, we have to know which mouse
3429  auto mousePressPos = devPriv->pointById(0)->eventPoint.globalPressPosition();
3430  if (popup->geometry().contains(mousePressPos.toPoint())
3431  || popup->testAttribute(Qt::WA_NoMouseReplay)) {
3432  // mouse release event or inside
3434  } else { // mouse press event
3436  }
3437 
3438  // transfer grab back to mouse grabber if any, otherwise release the grab
3439  ungrabMouseForPopup(popup);
3440 
3441  // transfer grab back to keyboard grabber if any, otherwise release the grab
3442  ungrabKeyboardForPopup(popup);
3443  }
3444 
3445  if (active_window) {
3446  if (QWidget *fw = active_window->focusWidget()) {
3447  if (fw != QApplication::focusWidget()) {
3448  fw->setFocus(Qt::PopupFocusReason);
3449  } else {
3452  }
3453  }
3454  }
3455 
3456  } else {
3457  // A popup was closed, so the previous popup gets the focus.
3459  if (QWidget *fw = aw->focusWidget())
3461 
3462  // can become nullptr due to setFocus() above
3464  QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
3465  grabForPopup(aw);
3466  }
3467 
3468 }
3469 
3471 
3473 {
3474  openPopupCount++;
3475  if (!popupWidgets) // create list
3476  popupWidgets = new QWidgetList;
3477  popupWidgets->append(popup); // add to end of list
3478 
3479  if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
3480  grabForPopup(popup);
3481 
3482  // popups are not focus-handled by the window system (the first
3483  // popup grabbed the keyboard), so we have to do that manually: A
3484  // new popup gets the focus
3485  if (popup->focusWidget()) {
3487  } else if (popupWidgets->count() == 1) { // this was the first popup
3488  if (QWidget *fw = QApplication::focusWidget()) {
3491  }
3492  }
3493 }
3494 
3495 #ifdef QT_KEYPAD_NAVIGATION
3503 void QApplication::setNavigationMode(Qt::NavigationMode mode)
3504 {
3505  QApplicationPrivate::navigationMode = mode;
3506 }
3507 
3515 Qt::NavigationMode QApplication::navigationMode()
3516 {
3517  return QApplicationPrivate::navigationMode;
3518 }
3519 #endif
3520 
3543 void QApplication::alert(QWidget *widget, int duration)
3544 {
3545  if (widget) {
3547  return;
3549  window->alert(duration);
3550  } else {
3551  const auto topLevels = topLevelWidgets();
3552  for (QWidget *topLevel : topLevels)
3553  QApplication::alert(topLevel, duration);
3554  }
3555 }
3556 
3576 {
3578 }
3579 
3581 {
3583 }
3584 
3594 {
3596 }
3597 
3599 {
3601 }
3602 
3613 {
3615 }
3616 
3618 {
3620 }
3621 
3639 #if QT_CONFIG(wheelevent)
3640 int QApplication::wheelScrollLines()
3641 {
3642  return styleHints()->wheelScrollLines();
3643 }
3644 
3645 void QApplication::setWheelScrollLines(int lines)
3646 {
3647  styleHints()->setWheelScrollLines(lines);
3648 }
3649 #endif
3650 
3651 static inline int uiEffectToFlag(Qt::UIEffect effect)
3652 {
3653  switch (effect) {
3654  case Qt::UI_General:
3656  case Qt::UI_AnimateMenu:
3658  case Qt::UI_FadeMenu:
3660  case Qt::UI_AnimateCombo:
3662  case Qt::UI_AnimateTooltip:
3664  case Qt::UI_FadeTooltip:
3666  case Qt::UI_AnimateToolBox:
3668  }
3669  return 0;
3670 }
3671 
3684 {
3685  int effectFlags = uiEffectToFlag(effect);
3686  if (enable) {
3687  if (effectFlags & QPlatformTheme::FadeMenuUiEffect)
3688  effectFlags |= QPlatformTheme::AnimateMenuUiEffect;
3689  if (effectFlags & QPlatformTheme::FadeTooltipUiEffect)
3692  } else {
3694  }
3695 }
3696 
3711 {
3712  CHECK_QAPP_INSTANCE(false)
3713  return QColormap::instance().depth() >= 16
3715  && (QApplicationPrivate::enabledAnimations & uiEffectToFlag(effect));
3716 }
3717 
3725 {
3727 }
3728 
3741 {
3742  return QGuiApplication::sendSpontaneousEvent(receiver, event);
3743 }
3744 
3745 void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEvent *event, QPoint localPos)
3746 {
3747  const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
3748  Qt::FocusPolicy focusPolicy = Qt::ClickFocus;
3749  static QPointer<QWidget> focusedWidgetOnTouchBegin = nullptr;
3750 
3751  switch (event->type()) {
3754  case QEvent::TouchBegin:
3755  focusedWidgetOnTouchBegin = QApplication::focusWidget();
3756  if (setFocusOnRelease)
3757  return;
3758  break;
3760  case QEvent::TouchEnd:
3761  if (!setFocusOnRelease)
3762  return;
3763  if (focusedWidgetOnTouchBegin != QApplication::focusWidget()) {
3764  // Focus widget was changed while delivering press/move events.
3765  // To not interfere with application logic, we leave focus as-is
3766  return;
3767  }
3768  break;
3769  case QEvent::Wheel:
3770  focusPolicy = Qt::WheelFocus;
3771  break;
3772  default:
3773  return;
3774  }
3775 
3776  QWidget *focusWidget = widget;
3777  while (focusWidget) {
3778  if (focusWidget->isEnabled()
3779  && focusWidget->rect().contains(localPos)
3780  && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
3781  focusWidget->setFocus(Qt::MouseFocusReason);
3782  break;
3783  }
3784  if (focusWidget->isWindow())
3785  break;
3786 
3787  // find out whether this widget (or its proxy) already has focus
3788  QWidget *f = focusWidget;
3789  if (focusWidget->d_func()->extra && focusWidget->d_func()->extra->focus_proxy)
3790  f = focusWidget->d_func()->extra->focus_proxy;
3791  // if it has, stop here.
3792  // otherwise a click on the focused widget would remove its focus if ClickFocus isn't set
3793  if (f->hasFocus())
3794  break;
3795 
3796  localPos += focusWidget->pos();
3797  focusWidget = focusWidget->parentWidget();
3798  }
3799 }
3800 
3801 bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
3802 {
3803  QWidget *f = w;
3804  while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
3805  f = f->d_func()->extra->focus_proxy;
3806 
3807  if ((w->focusPolicy() & policy) != policy)
3808  return false;
3809  if (w != f && (f->focusPolicy() & policy) != policy)
3810  return false;
3811  return true;
3812 }
3813 
3815 {
3816  bool containsPress = false;
3817 
3818  for (int i = 0; i < touchEvent->pointCount(); ++i) {
3819  auto &pt = touchEvent->point(i);
3820  QMutableEventPoint::setPosition(pt, widget->mapFromGlobal(pt.globalPosition()));
3821 
3822  if (pt.state() == QEventPoint::State::Pressed)
3823  containsPress = true;
3824  }
3825  return containsPress;
3826 }
3827 
3829 {
3831 }
3832 
3834 {
3835 }
3836 
3838 {
3840 }
3841 
3843 {
3844 }
3845 
3847 {
3848  const QPointF globalPos = touchPoint.globalPosition();
3849  int closestTouchPointId = -1;
3850  QObject *closestTarget = nullptr;
3851  qreal closestDistance = 0;
3853  for (auto &epd : devPriv->activePoints.values()) {
3854  const auto &pt = epd.eventPoint;
3855  if (pt.id() != touchPoint.id()) {
3856  qreal dx = globalPos.x() - pt.globalPosition().x();
3857  qreal dy = globalPos.y() - pt.globalPosition().y();
3858  qreal distance = dx * dx + dy * dy;
3859  if (closestTouchPointId == -1 || distance < closestDistance) {
3860  closestTouchPointId = pt.id();
3861  closestDistance = distance;
3862  closestTarget = QMutableEventPoint::target(pt);
3863  }
3864  }
3865  }
3866  return static_cast<QWidget *>(closestTarget);
3867 }
3868 
3870  ImplicitTouchGrabMode grabMode)
3871 {
3872  if (touchEvent->type() != QEvent::TouchBegin)
3873  return;
3874 
3875  // If the widget dispatched the event further (see QGraphicsProxyWidget), then
3876  // there might already be an implicit grabber. Don't override that. A widget that
3877  // has partially recognized a gesture needs to grab all points.
3878  for (int i = 0; i < touchEvent->pointCount(); ++i) {
3879  auto &ep = touchEvent->point(i);
3880  if (!QMutableEventPoint::target(ep) && (ep.isAccepted() || grabMode == GrabAllPoints))
3881  QMutableEventPoint::setTarget(ep, widget);
3882  }
3883  // TODO setExclusiveGrabber() to be consistent with Qt Quick?
3884 }
3885 
3887 {
3888  QApplicationPrivate *d = self;
3889  // TODO get rid of this QPair
3890  typedef QPair<QEventPoint::State, QList<QEventPoint> > StatesAndTouchPoints;
3891  QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
3892 
3893  const auto *device = te->pointingDevice();
3894  auto touchPoints = te->points(); // touch points will be mutated
3895  for (auto &touchPoint : touchPoints) {
3896  // update state
3898  if (touchPoint.state() == QEventPoint::State::Pressed) {
3899  if (device->type() == QInputDevice::DeviceType::TouchPad) {
3900  // on touchpads, send all touch points to the same widget:
3901  // pick the first non-null target if possible
3903  }
3904 
3905  if (target.isNull()) {
3906  // determine which widget this event will go to
3907  if (!window)
3908  window = QApplication::topLevelAt(touchPoint.globalPosition().toPoint());
3909  if (!window)
3910  continue;
3911  target = window->childAt(window->mapFromGlobal(touchPoint.globalPosition().toPoint()));
3912  if (!target)
3913  target = window;
3914  }
3915 
3916  bool usingClosestWidget = false;
3918  QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint);
3919  QWidget *widget = static_cast<QWidget *>(target.data());
3920  if (closestWidget
3921  && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) {
3922  target = closestWidget;
3923  usingClosestWidget = true;
3924  }
3925  }
3926 
3927  // on touch pads, implicitly grab all touch points
3928  // on touch screens, grab touch points that are redirected to the closest widget
3929  if (device->type() == QInputDevice::DeviceType::TouchPad || usingClosestWidget)
3930  QMutableEventPoint::setTarget(touchPoint, target);
3931  } else {
3932  target = QMutableEventPoint::target(touchPoint);
3933  if (!target)
3934  continue;
3935  }
3936  Q_ASSERT(!target.isNull());
3937 
3938  QWidget *targetWidget = static_cast<QWidget *>(target.data());
3939 
3940 #ifdef Q_OS_MACOS
3941  // Single-touch events are normally not sent unless WA_TouchPadAcceptSingleTouchEvents is set.
3942  // In Qt 4 this check was in OS X-only code. That behavior is preserved here by the #ifdef.
3943  if (touchPoints.count() == 1
3946  continue;
3947 #endif
3948 
3949  StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[targetWidget];
3950  maskAndPoints.first = QEventPoint::State(maskAndPoints.first | touchPoint.state());
3951  maskAndPoints.second.append(touchPoint);
3952  }
3953 
3954  if (widgetsNeedingEvents.isEmpty())
3955  return false;
3956 
3957  bool accepted = false;
3960  for (; it != end; ++it) {
3961  const QPointer<QWidget> widget = it.key();
3963  continue;
3964 
3965  QEvent::Type eventType;
3966  switch (it.value().first) {
3967  case QEventPoint::State::Pressed:
3968  eventType = QEvent::TouchBegin;
3969  break;
3970  case QEventPoint::State::Released:
3971  eventType = QEvent::TouchEnd;
3972  break;
3973  case QEventPoint::State::Stationary:
3974  // don't send the event if nothing changed
3975  continue;
3976  default:
3977  eventType = QEvent::TouchUpdate;
3978  break;
3979  }
3980 
3982  it.value().second);
3983  bool containsPress = updateTouchPointsForWidget(widget, &touchEvent);
3984  touchEvent.setTimestamp(te->timestamp());
3985  touchEvent.setTarget(widget);
3986 
3987  if (containsPress)
3989 
3990  switch (touchEvent.type()) {
3991  case QEvent::TouchBegin:
3992  {
3993  // if the TouchBegin handler recurses, we assume that means the event
3994  // has been implicitly accepted and continue to send touch events
3995  bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
3997  if (res && touchEvent.isAccepted()) {
3998  accepted = true;
3999  if (!widget.isNull())
4001  }
4002  break;
4003  }
4004  default:
4006 #ifndef QT_NO_GESTURES
4008 #endif
4009  ) {
4010  bool res = te->spontaneous() ? QApplication::sendSpontaneousEvent(widget, &touchEvent)
4012  if (res && touchEvent.isAccepted())
4013  accepted = true;
4014  // widget can be deleted on TouchEnd
4015  if (touchEvent.type() == QEvent::TouchEnd && !widget.isNull())
4017  }
4018  break;
4019  }
4020  }
4021  return accepted;
4022 }
4023 
4025 {
4027  touchEvent.setTimestamp(timestamp);
4028 
4029  QSet<QWidget *> widgetsNeedingCancel;
4031  for (auto &epd : devPriv->activePoints.values()) {
4032  const auto &pt = epd.eventPoint;
4034  if (target && target->isWidgetType())
4035  widgetsNeedingCancel.insert(static_cast<QWidget *>(target));
4036  }
4037  for (QSet<QWidget *>::const_iterator widIt = widgetsNeedingCancel.constBegin(),
4038  widItEnd = widgetsNeedingCancel.constEnd(); widIt != widItEnd; ++widIt) {
4039  QWidget *widget = *widIt;
4040  touchEvent.setTarget(widget);
4041  QApplication::sendSpontaneousEvent(widget, &touchEvent);
4042  }
4043 }
4044 
4046 {
4048 
4050 }
4051 
4052 #if QT_CONFIG(draganddrop)
4053 void QApplicationPrivate::notifyDragStarted(const QDrag *drag)
4054 {
4055  QGuiApplicationPrivate::notifyDragStarted(drag);
4056  // QTBUG-26145
4057  // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation...
4058  // QTBUG-56713
4059  // ...only if qt_button_down is not a QQuickWidget
4060  if (qt_button_down && !qt_button_down->inherits("QQuickWidget"))
4061  qt_button_down = nullptr;
4062 }
4063 #endif // QT_CONFIG(draganddrop)
4064 
4065 #ifndef QT_NO_GESTURES
4067 {
4069  if (!qAppPriv)
4070  return nullptr;
4071  if (!qAppPriv->gestureManager && ic == ForceCreation)
4072  qAppPriv->gestureManager = new QGestureManager(qApp);
4073  return qAppPriv->gestureManager;
4074 }
4075 #endif // QT_NO_GESTURES
4076 
4078 {
4079  QStyleOption opt(0);
4082 }
4083 
4084 void *QApplication::resolveInterface(const char *name, int revision) const
4085 {
4086  return QGuiApplication::resolveInterface(name, revision);
4087 }
4088 
4090 
4091 #include "moc_qapplication.cpp"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
Arabic default style
Definition: afstyles.h:94
enum State_ State
static void(* setWidgetParent)(QObject *, QObject *)
Definition: qobject_p.h:95
static void installFactory(InterfaceFactory)
The QApplication class manages the GUI application's control flow and main settings.
Definition: qapplication.h:68
static QStyle * style()
static void setStyle(QStyle *)
static void aboutQt()
static void closeAllWindows()
static void beep()
virtual ~QApplication()
static bool isEffectEnabled(Qt::UIEffect)
static void setPalette(const QPalette &, const char *className=nullptr)
static QWidget * widgetAt(const QPoint &p)
static void alert(QWidget *widget, int duration=0)
static QPalette palette()
static QWidget * activeModalWidget()
static QWidget * topLevelAt(const QPoint &p)
static QWidget * focusWidget()
static QWidgetList topLevelWidgets()
static QFont font()
bool autoSipEnabled
toggles automatic SIP (software input panel) visibility
Definition: qapplication.h:81
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
static QWidget * activePopupWidget()
static int exec()
int startDragTime
the time in milliseconds that a mouse button must be held down before a drag and drop operation will ...
Definition: qapplication.h:76
static void setCursorFlashTime(int)
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
int doubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
Definition: qapplication.h:71
int cursorFlashTime
the text cursor's flash (blink) time in milliseconds
Definition: qapplication.h:70
static void setStartDragTime(int ms)
int startDragDistance
the minimum distance required for a drag and drop operation to start.
Definition: qapplication.h:77
bool event(QEvent *) override
void setAutoSipEnabled(const bool enabled)
bool notify(QObject *, QEvent *) override
static void setStartDragDistance(int l)
static QWidget * activeWindow()
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override
int keyboardInputInterval
the time limit in milliseconds that distinguishes a key press from two consecutive key presses
Definition: qapplication.h:72
void setStyleSheet(const QString &sheet)
QString styleSheet
the application style sheet
Definition: qapplication.h:79
static void setKeyboardInputInterval(int)
static void setActiveWindow(QWidget *act)
static void setFont(const QFont &, const char *className=nullptr)
static void setDoubleClickInterval(int)
static QWidgetList allWidgets()
static QWidget * pickMouseReceiver(QWidget *candidate, const QPoint &windowPos, QPoint *pos, QEvent::Type type, Qt::MouseButtons buttons, QWidget *buttonDown, QWidget *alienWidget)
virtual void notifyLayoutDirectionChange() override
static void initializeWidgetPalettesFromTheme()
void handlePaletteChanged(const char *className=nullptr) override
void sendSyntheticEnterLeave(QWidget *widget)
static QWidget * desktop()
static QWindow * windowForWidget(const QWidget *widget)
QApplicationPrivate(int &argc, char **argv, int flags)
static bool modalState()
static QWidget * focus_widget
static QPointer< QWidget > leaveAfterRelease
QGestureManager * gestureManager
static void initializeWidgetFontHash()
void notifyThemeChanged() override
bool notify_helper(QObject *receiver, QEvent *e)
virtual void notifyActiveWindowChange(QWindow *) override
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow=nullptr) const override
static QWidget * hidden_focus_widget
QPalette basePalette() const override
static QWidget * active_window
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
void closePopup(QWidget *popup)
static PaletteHash widgetPalettes
static int enabledAnimations
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next, bool *wrappingOccurred=nullptr)
static QString styleSheet
static bool widgetCount
QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap &base) const override
static bool inPopupMode()
static QFont * sys_font
void openPopup(QWidget *popup)
static QWidgetList * popupWidgets
void activateImplicitTouchGrab(QWidget *widget, QTouchEvent *touchBeginEvent, ImplicitTouchGrabMode grabMode=GrabAcceptedPoints)
void notifyWindowIconChanged() override
QWidget * findClosestTouchPointTarget(const QPointingDevice *device, const QEventPoint &touchPoint)
bool closeAllPopups() override
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF)
static QString desktopStyleKey()
static bool isBlockedByModal(QWidget *widget)
static QStyle * app_style
void createEventDispatcher() override
static QWidget * main_widget
static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent)
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true, bool onlyDispatchEnterLeave=false)
static void setSystemFont(const QFont &font)
static bool autoSipEnabled
static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
static QApplicationPrivate * instance()
static bool tryModalHelper(QWidget *widget, QWidget **rettop=nullptr)
static QFont * set_font
static void translateTouchCancel(const QPointingDevice *device, ulong timestamp)
static void cleanup()
Definition: qcolormap.cpp:83
static void initialize()
Definition: qcolormap.cpp:64
static QColormap instance(int screen=-1)
Definition: qcolormap.cpp:89
int depth() const
Definition: qcolormap.cpp:112
The QContextMenuEvent class contains parameters that describe a context menu event....
Definition: qevent.h:665
void * resolveInterface(const char *name, int revision) const
static QCoreApplication * instance()
static bool sendEvent(QObject *receiver, QEvent *event)
bool event(QEvent *) override
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
[95]
static bool testAttribute(Qt::ApplicationAttribute attribute)
friend class QApplication
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
static void setEventSpontaneous(QEvent *e, bool spontaneous)
static void checkReceiverThread(QObject *receiver)
static QPoint pos()
Definition: qcursor.cpp:224
The QDrag class provides support for MIME-based drag and drop data transfer.
Definition: qdrag.h:58
void setCurrentTarget(QObject *target, bool dropped=false)
Definition: qdnd.cpp:80
static QDragManager * self()
Definition: qdnd.cpp:66
The QEnterEvent class contains parameters that describe an enter event.
Definition: qevent.h:197
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
bool spontaneous() const
Definition: qcoreevent.h:308
@ QueryWhatsThis
Definition: qcoreevent.h:182
@ OrientationChange
Definition: qcoreevent.h:275
@ TabletMove
Definition: qcoreevent.h:134
@ MetaCall
Definition: qcoreevent.h:110
@ GraphicsSceneDragLeave
Definition: qcoreevent.h:213
@ ApplicationPaletteChange
Definition: qcoreevent.h:106
@ CloseSoftwareInputPanel
Definition: qcoreevent.h:262
@ Gesture
Definition: qcoreevent.h:266
@ ApplicationDeactivate
Definition: qcoreevent.h:179
@ StatusTip
Definition: qcoreevent.h:162
@ GestureOverride
Definition: qcoreevent.h:267
@ DragResponse
Definition: qcoreevent.h:118
@ IconDrag
Definition: qcoreevent.h:144
@ FocusAboutToChange
Definition: qcoreevent.h:81
@ EnterWhatsThisMode
Definition: qcoreevent.h:183
@ DragMove
Definition: qcoreevent.h:115
@ ChildPolished
Definition: qcoreevent.h:120
@ ToolTip
Definition: qcoreevent.h:160
@ ApplicationLayoutDirectionChange
Definition: qcoreevent.h:105
@ GraphicsSceneDragEnter
Definition: qcoreevent.h:211
@ GraphicsSceneDragMove
Definition: qcoreevent.h:212
@ ApplicationWindowIconChange
Definition: qcoreevent.h:103
@ ShortcutOverride
Definition: qcoreevent.h:171
@ FocusOut
Definition: qcoreevent.h:80
@ ChildRemoved
Definition: qcoreevent.h:121
@ DeferredDelete
Definition: qcoreevent.h:113
@ StyleChange
Definition: qcoreevent.h:149
@ NativeGesture
Definition: qcoreevent.h:259
@ DragEnter
Definition: qcoreevent.h:114
@ Enter
Definition: qcoreevent.h:82
@ LocaleChange
Definition: qcoreevent.h:135
@ LayoutRequest
Definition: qcoreevent.h:125
@ KeyRelease
Definition: qcoreevent.h:78
@ Leave
Definition: qcoreevent.h:83
@ MouseMove
Definition: qcoreevent.h:76
@ KeyPress
Definition: qcoreevent.h:77
@ Paint
Definition: qcoreevent.h:84
@ Resize
Definition: qcoreevent.h:86
@ FocusIn
Definition: qcoreevent.h:79
@ TouchCancel
Definition: qcoreevent.h:277
@ ActivationChange
Definition: qcoreevent.h:148
@ MouseButtonPress
Definition: qcoreevent.h:73
@ TouchEnd
Definition: qcoreevent.h:256
@ TouchUpdate
Definition: qcoreevent.h:255
@ TouchBegin
Definition: qcoreevent.h:254
@ HoverLeave
Definition: qcoreevent.h:189
@ HoverEnter
Definition: qcoreevent.h:188
@ WindowActivate
Definition: qcoreevent.h:96
@ LanguageChange
Definition: qcoreevent.h:136
@ TabletRelease
Definition: qcoreevent.h:140
@ DynamicPropertyChange
Definition: qcoreevent.h:220
@ UpdateRequest
Definition: qcoreevent.h:126
@ DragLeave
Definition: qcoreevent.h:116
@ RequestSoftwareInputPanel
Definition: qcoreevent.h:261
@ Timer
Definition: qcoreevent.h:72
@ GraphicsSceneDrop
Definition: qcoreevent.h:214
@ WhatsThisClicked
Definition: qcoreevent.h:173
@ UpdateLater
Definition: qcoreevent.h:127
@ HoverMove
Definition: qcoreevent.h:190
@ TabletPress
Definition: qcoreevent.h:139
@ MouseButtonDblClick
Definition: qcoreevent.h:75
@ NetworkReplyUpdated
Definition: qcoreevent.h:244
@ ApplicationFontChange
Definition: qcoreevent.h:104
@ WhatsThis
Definition: qcoreevent.h:161
@ Quit
Definition: qcoreevent.h:92
@ WindowDeactivate
Definition: qcoreevent.h:97
@ Move
Definition: qcoreevent.h:85
@ ContextMenu
Definition: qcoreevent.h:132
@ MouseButtonRelease
Definition: qcoreevent.h:74
@ ChildAdded
Definition: qcoreevent.h:119
Type type() const
Definition: qcoreevent.h:307
bool isAccepted() const
Definition: qcoreevent.h:311
quint16 t
Definition: qcoreevent.h:331
The QEventPoint class provides information about a point in a QPointerEvent.
Definition: qeventpoint.h:56
const mapped_container_type & values() const noexcept
Definition: qflatmap_p.h:594
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
Definition: qevent.h:520
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
bool isCopyOf(const QFont &) const
Definition: qfont.cpp:1865
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:56
The QGestureEvent class provides the description of triggered gestures.
Definition: qgesture.h:276
bool isAccepted(QGesture *) const
Definition: qgesture.cpp:991
QList< QGesture * > gestures() const
Definition: qgesture.cpp:897
void setAccepted(QGesture *, bool)
Definition: qgesture.cpp:952
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:62
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:67
static bool gesturePending(QObject *o)
static QGestureManager * instance(InstanceCreation ic=ForceCreation)
QGestureManager(QObject *parent)
The QGuiApplication class manages the GUI application's control flow and main settings.
static QPlatformNativeInterface * platformNativeInterface()
static QWindowList topLevelWindows()
static QWindow * modalWindow()
static QWindow * topLevelAt(const QPoint &pos)
static void setFont(const QFont &)
static QPalette palette()
static void setPalette(const QPalette &pal)
static QFont font()
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override
static QStyleHints * styleHints()
static QInputMethod * inputMethod()
static Qt::KeyboardModifiers keyboardModifiers()
bool event(QEvent *) override
static bool desktopSettingsAware()
static QPlatformIntegration * platformIntegration()
static QPlatformTheme * platformTheme()
static QWindow * focus_window
static void captureGlobalModifierState(QEvent *e)
virtual void handlePaletteChanged(const char *className=nullptr)
void createEventDispatcher() override
static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event)
virtual void notifyThemeChanged()
The QHash::const_iterator class provides an STL-style const iterator for QHash.
Definition: qhash.h:1088
const_iterator constEnd() const noexcept
Definition: qhash.h:1162
const_iterator constBegin() const noexcept
Definition: qhash.h:1158
friend class const_iterator
Definition: qhash.h:1125
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Definition: qhash.h:904
bool isEmpty() const noexcept
Definition: qhash.h:881
iterator insert(const Key &key, const T &value)
Definition: qhash.h:1228
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:873
The QHoverEvent class contains parameters that describe a mouse event.
Definition: qevent.h:281
Mode
Definition: qicon.h:58
quint64 timestamp() const
Definition: qevent.h:87
Qt::KeyboardModifiers modifiers() const
Definition: qevent.h:85
The QKeyEvent class describes a key event.
Definition: qevent.h:471
int count() const
Definition: qevent.h:495
Qt::KeyboardModifiers modifiers() const
Definition: qevent.cpp:1502
QString text() const
Definition: qevent.h:493
bool isAutoRepeat() const
Definition: qevent.h:494
int key() const
Definition: qevent.h:484
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:62
void widgetEvent(QEvent *)
Definition: qlayout.cpp:557
qsizetype size() const noexcept
Definition: qlist.h:414
bool isEmpty() const noexcept
Definition: qlist.h:418
void removeAt(qsizetype i)
Definition: qlist.h:588
bool removeOne(const AT &t)
Definition: qlist.h:596
const_reference at(qsizetype i) const noexcept
Definition: qlist.h:457
const_reverse_iterator crbegin() const noexcept
Definition: qlist.h:636
const_iterator constBegin() const noexcept
Definition: qlist.h:630
qsizetype removeAll(const AT &t)
Definition: qlist.h:590
qsizetype count() const noexcept
Definition: qlist.h:415
const T & constLast() const noexcept
Definition: qlist.h:648
void append(parameter_type t)
Definition: qlist.h:469
const_iterator constEnd() const noexcept
Definition: qlist.h:631
const_iterator ConstIterator
Definition: qlist.h:280
const_reverse_iterator crend() const noexcept
Definition: qlist.h:637
Definition: qmap.h:222
T value(const Key &key, const T &defaultValue=T()) const
Definition: qmap.h:392
iterator find(const Key &key)
Definition: qmap.h:672
iterator end()
Definition: qmap.h:637
static void aboutQt(QWidget *parent, const QString &title=QString())
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:231
The QMoveEvent class contains event parameters for move events. \inmodule QtGui.
Definition: qevent.h:558
const QPoint & pos() const
Definition: qevent.h:566
static QObject * target(const QEventPoint &p)
static QMutableSinglePointEvent * from(QSinglePointEvent *e)
Definition: qevent_p.h:93
void setDoubleClick(bool d=true)
Definition: qevent_p.h:101
static QMutableTouchEvent * from(QTouchEvent *e)
Definition: qevent_p.h:73
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
bool isWindowType() const
Definition: qobject.h:149
QObject * parent() const
Definition: qobject.h:409
virtual bool event(QEvent *event)
Definition: qobject.cpp:1329
void setParent(QObject *parent)
Definition: qobject.cpp:2108
QThread * thread() const
Definition: qobject.cpp:1527
bool inherits(const char *classname) const
Definition: qobject.h:411
bool isWidgetType() const
Definition: qobject.h:148
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:55
void setResolveMask(ResolveMask mask)
Definition: qpalette.cpp:964
ResolveMask resolveMask() const
Definition: qpalette.cpp:956
static void clear()
The QPixmap class is an off-screen image representation that can be used as a paint device.
Definition: qpixmap.h:63
virtual void beep() const
virtual NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource)
virtual const QPalette * palette(Palette type=SystemPalette) const
virtual const QFont * font(Font type=SystemFont) const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
constexpr qreal x() const noexcept
Definition: qpoint.h:361
constexpr qreal y() const noexcept
Definition: qpoint.h:366
constexpr QPoint toPoint() const
Definition: qpoint.h:420
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
const QPointingDevice * pointingDevice() const
Definition: qevent.cpp:354
void setTimestamp(quint64 timestamp) override
Definition: qevent.cpp:362
virtual void setAccepted(bool accepted) override
Definition: qevent.cpp:342
const QList< QEventPoint > & points() const
Definition: qevent.h:118
bool isNull() const
Definition: qpointer.h:87
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static const QPointingDevice * primaryPointingDevice(const QString &seatName=QString())
QObject * firstActiveTarget() const
static QPointingDevicePrivate * get(QPointingDevice *q)
Definition: qthread_p.h:76
QObject * receiver
Definition: qthread_p.h:78
QEvent * event
Definition: qthread_p.h:79
Definition: qthread_p.h:98
The QRectF class defines a finite rectangle in the plane using floating point precision.
Definition: qrect.h:511
bool contains(const QRectF &r) const noexcept
Definition: qrect.cpp:2006
bool contains(const QRect &r, bool proper=false) const noexcept
Definition: qrect.cpp:887
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:63
bool isEmpty() const
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
Definition: qevent.h:612
const QSize & size() const
Definition: qevent.h:620
QList< T > values() const
Definition: qset.h:333
const_iterator ConstIterator
Definition: qset.h:189
const_iterator constBegin() const noexcept
Definition: qset.h:175
const_iterator constEnd() const noexcept
Definition: qset.h:179
iterator insert(const T &value)
Definition: qset.h:191
QPointF globalPosition() const
Definition: qevent.h:154
QPointF position() const
Definition: qevent.h:150
QPointF scenePosition() const
Definition: qevent.h:152
Qt::MouseButton button() const
Definition: qevent.h:147
Qt::MouseButtons buttons() const
Definition: qevent.h:148
The QString class provides a Unicode character string.
Definition: qstring.h:388
static QString fromLocal8Bit(QByteArrayView ba)
Definition: qstring.cpp:5563
bool isEmpty() const
Definition: qstring.h:1216
QString & append(QChar c)
Definition: qstring.cpp:3152
The QStringList class provides a list of strings.
static QStringList keys()
static QStyle * create(const QString &)
void setKeyboardInputInterval(int keyboardInputInterval)
void setWheelScrollLines(int scrollLines)
int keyboardInputInterval
the time limit, in milliseconds, that distinguishes a key press from two consecutive key presses.
Definition: qstylehints.h:60
void setStartDragDistance(int startDragDistance)
int startDragTime
the time, in milliseconds, that a mouse button must be held down before a drag and drop operation wil...
Definition: qstylehints.h:73
int startDragDistance
the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop ...
Definition: qstylehints.h:72
bool setFocusOnTouchRelease
the event that should set input focus on focus objects.
Definition: qstylehints.h:67
Qt::TabFocusBehavior tabFocusBehavior
The focus behavior on press of the tab key.
Definition: qstylehints.h:77
void setCursorFlashTime(int cursorFlashTime)
int mouseDoubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.
Definition: qstylehints.h:62
int cursorFlashTime
the text cursor's flash (blink) time in milliseconds.
Definition: qstylehints.h:56
int wheelScrollLines
Number of lines to scroll by default for each wheel click.
Definition: qstylehints.h:81
void setMouseDoubleClickInterval(int mouseDoubleClickInterval)
void setStartDragTime(int startDragTime)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition: qstyle.h:65
virtual void polish(QWidget *widget)
Definition: qstyle.cpp:472
virtual QPalette standardPalette() const
Definition: qstyle.cpp:2335
@ SH_Widget_ShareActivation
Definition: qstyle.h:642
@ SH_ToolTip_FallAsleepDelay
Definition: qstyle.h:718
@ SH_ToolTip_WakeUpDelay
Definition: qstyle.h:717
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
virtual void unpolish(QWidget *widget)
Definition: qstyle.cpp:491
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:75
QPalette palette
Definition: qstyleoption.h:99
void repolish(QWidget *widget)
QEventPoint & point(int touchId)
QMap< int, QEventPoint > points
static QThread * currentThread()
Definition: qthread.cpp:879
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:367
int timerId() const
Definition: qcoreevent.h:372
static void setPalette(const QPalette &)
Definition: qtooltip.cpp:578
The QTouchEvent class contains parameters that describe a touch event.
Definition: qevent.h:1020
static void enterWhatsThisMode()
Definition: qwhatsthis.cpp:537
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
QWidget * window() const
Definition: qwidget.cpp:4319
WId internalWinId() const
Definition: qwidget.h:251
QPointF mapToGlobal(const QPointF &) const
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:140
QLayout * layout() const
Definition: qwidget.cpp:10115
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:145
bool close()
Definition: qwidget.cpp:8468
QFontMetrics fontMetrics() const
Definition: qwidget.h:880
QWidget * focusWidget() const
Definition: qwidget.cpp:6810
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
static QWidget * mouseGrabber()
Definition: qwidget.cpp:12662
QWindow * windowHandle() const
Definition: qwidget.cpp:2495
static QWidget * keyboardGrabber()
Definition: qwidget.cpp:12679
QPointF mapFrom(const QWidget *, const QPointF &) const
WId effectiveWinId() const
Definition: qwidget.cpp:2474
QStyle * style() const
Definition: qwidget.cpp:2612
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:174
QWidget * parentWidget() const
Definition: qwidget.h:937
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:169
bool isWindow() const
Definition: qwidget.h:844
Qt::WindowStates windowState() const
Definition: qwidget.cpp:2900
bool isAncestorOf(const QWidget *child) const
Definition: qwidget.cpp:8728
bool isActiveWindow
whether this widget's window is the active window
Definition: qwidget.h:173
QPointF mapToParent(const QPointF &) const
bool isVisible() const
Definition: qwidget.h:907
QPointF mapFromGlobal(const QPointF &) const
Qt::WindowType windowType() const
Definition: qwidget.h:834
void setCursor(const QCursor &)
Definition: qwidget.cpp:4966
bool testAttribute(Qt::WidgetAttribute) const
Definition: qwidget.h:943
static int instanceCounter
Definition: qwidget_p.h:720
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
Definition: qwidget_p.h:731
static QWidgetMapper * mapper
Definition: qwidget_p.h:680
bool stealKeyboardGrab(bool grab)
Definition: qwidget.cpp:12627
static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent)
Definition: qwidget.cpp:12942
bool stealMouseGrab(bool grab)
Definition: qwidget.cpp:12578
static int maxInstances
Definition: qwidget_p.h:721
static QWidgetSet * allWidgets
Definition: qwidget_p.h:681
QWidget * widget() const
The QWindow class represents a window in the underlying windowing system.
Definition: qwindow.h:99
Qt::WindowModality modality
the modality of the window
Definition: qwindow.h:114
static QWindowPrivate * get(QWindow *window)
Definition: qwindow_p.h:125
Definition: base.h:37
QOpenGLWidget * widget
[1]
QHash< int, QWidget * > hash
[35multi]
QString text
[meta data]
bool focus
[0]
double e
QStyleOptionButton opt
fontMetrics
palette
short next
Definition: keywords.cpp:454
typename C::const_iterator const_iterator
const PluginKeyMapConstIterator cend
std::chrono::milliseconds ms
QTouchEventSequence touchEvent(QWindow *window, QPointingDevice *device, bool autoCommit=true)
Definition: qtesttouch.h:78
QFuture< typename std::decay_t< Sequence >::value_type > filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
@ WindowMinimized
Definition: qnamespace.h:278
NavigationMode
Definition: qnamespace.h:1676
@ NavigationModeKeypadTabOrder
Definition: qnamespace.h:1678
@ TabFocusAllControls
Definition: qnamespace.h:143
@ NoButton
Definition: qnamespace.h:82
@ WA_AcceptTouchEvents
Definition: qnamespace.h:429
@ WA_UnderMouse
Definition: qnamespace.h:309
@ WA_TouchPadAcceptSingleTouchEvents
Definition: qnamespace.h:431
@ WA_TransparentForMouseEvents
Definition: qnamespace.h:342
@ WA_MacMiniSize
Definition: qnamespace.h:388
@ WA_SetLocale
Definition: qnamespace.h:383
@ WA_AlwaysShowToolTips
Definition: qnamespace.h:379
@ WA_SetCursor
Definition: qnamespace.h:330
@ WA_Hover
Definition: qnamespace.h:365
@ WA_WState_Polished
Definition: qnamespace.h:357
@ WA_DontShowOnScreen
Definition: qnamespace.h:408
@ WA_NoMouseReplay
Definition: qnamespace.h:345
@ WA_KeyboardFocusChange
Definition: qnamespace.h:369
@ WA_SetStyle
Definition: qnamespace.h:381
@ WA_NoMousePropagation
Definition: qnamespace.h:364
@ WA_WState_AcceptedTouchBeginEvent
Definition: qnamespace.h:430
@ WA_WState_Created
Definition: qnamespace.h:352
@ WA_MacSmallSize
Definition: qnamespace.h:387
@ WA_InputMethodEnabled
Definition: qnamespace.h:320
WindowModality
Definition: qnamespace.h:1563
@ NonModal
Definition: qnamespace.h:1564
@ WindowModal
Definition: qnamespace.h:1565
@ ApplicationModal
Definition: qnamespace.h:1566
@ GestureStarted
Definition: qnamespace.h:1634
FocusPolicy
Definition: qnamespace.h:131
@ WheelFocus
Definition: qnamespace.h:136
@ ClickFocus
Definition: qnamespace.h:134
@ NoFocus
Definition: qnamespace.h:132
@ TabFocus
Definition: qnamespace.h:133
@ StrongFocus
Definition: qnamespace.h:135
@ gray
Definition: qnamespace.h:64
UIEffect
Definition: qnamespace.h:1166
@ UI_AnimateToolBox
Definition: qnamespace.h:1173
@ UI_FadeMenu
Definition: qnamespace.h:1169
@ UI_AnimateCombo
Definition: qnamespace.h:1170
@ UI_General
Definition: qnamespace.h:1167
@ UI_AnimateTooltip
Definition: qnamespace.h:1171
@ UI_AnimateMenu
Definition: qnamespace.h:1168
@ UI_FadeTooltip
Definition: qnamespace.h:1172
@ Key_Tab
Definition: qnamespace.h:685
@ Key_Right
Definition: qnamespace.h:700
@ Key_Backtab
Definition: qnamespace.h:686
@ Key_Left
Definition: qnamespace.h:698
@ Key_Up
Definition: qnamespace.h:699
@ Key_Down
Definition: qnamespace.h:701
@ NoModifier
Definition: qnamespace.h:1074
@ AA_SetPalette
Definition: qnamespace.h:473
@ AA_NativeWindows
Definition: qnamespace.h:453
@ CaseInsensitive
Definition: qnamespace.h:1283
GestureType
Definition: qnamespace.h:1641
@ ReceivePartialGestures
Definition: qnamespace.h:1656
ScrollPhase
Definition: qnamespace.h:1695
@ ScrollBegin
Definition: qnamespace.h:1697
@ ScrollUpdate
Definition: qnamespace.h:1698
@ ScrollMomentum
Definition: qnamespace.h:1700
@ NoScrollPhase
Definition: qnamespace.h:1696
@ ScrollEnd
Definition: qnamespace.h:1699
@ Desktop
Definition: qnamespace.h:240
@ Popup
Definition: qnamespace.h:236
@ Dialog
Definition: qnamespace.h:233
@ SubWindow
Definition: qnamespace.h:241
FocusReason
Definition: qnamespace.h:1360
@ PopupFocusReason
Definition: qnamespace.h:1365
@ BacktabFocusReason
Definition: qnamespace.h:1363
@ NoFocusReason
Definition: qnamespace.h:1369
@ MouseFocusReason
Definition: qnamespace.h:1361
@ OtherFocusReason
Definition: qnamespace.h:1368
@ ActiveWindowFocusReason
Definition: qnamespace.h:1364
@ TabFocusReason
Definition: qnamespace.h:1362
@ ShortcutFocusReason
Definition: qnamespace.h:1366
decltype(auto) cbegin(const T &t)
#define QString()
Definition: parse-defines.h:51
int PRIV() strcmp(PCRE2_SPTR str1, PCRE2_SPTR str2)
int PRIV() strncmp(PCRE2_SPTR str1, PCRE2_SPTR str2, size_t len)
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
void
Definition: png.h:1080
QT_BEGIN_NAMESPACE QAccessibleInterface * qAccessibleFactory(const QString &classname, QObject *object)
Q_CORE_EXPORT void qt_call_post_routines()
bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
void qt_init_tooltip_palette()
int openPopupCount
bool qt_replay_popup_mouse_event
return res
bool qt_popup_down_closed
Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
int qt_antialiasing_threshold
bool qt_in_tab_key_event
QWidget * qt_popup_down
QWidget * qt_desktopWidget
Q_WIDGETS_EXPORT QWidget * qt_button_down
QWidget * qt_tlw_for_window(QWindow *wnd)
void qRegisterWidgetsVariant()
void qt_cleanup()
#define CHECK_QAPP_INSTANCE(...)
FontHash * qt_app_fonts_hash()
QPointer< QWidget > qt_last_mouse_receiver
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
bool qt_try_modal(QWidget *widget, QEvent::Type type)
void qt_qpa_set_cursor(QWidget *w, bool force)
Definition: qwidget.cpp:5020
#define QApplicationPrivateBase
#define QByteArrayLiteral(str)
Definition: qbytearray.h:80
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define Q_FALLTHROUGH()
#define Q_UNLIKELY(x)
std::pair< T1, T2 > QPair
Definition: qcontainerfwd.h:56
#define qApp
bool qIsInf(qfloat16 f) noexcept
Definition: qfloat16.h:220
unsigned long ulong
Definition: qglobal.h:335
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
unsigned int uint
Definition: qglobal.h:334
unsigned short ushort
Definition: qglobal.h:333
#define Q_INIT_RESOURCE(name)
Definition: qglobal.h:582
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
Q_GUI_EXPORT bool qt_is_tty_app
#define qDebug
[1]
Definition: qlogging.h:177
#define qWarning
Definition: qlogging.h:179
GLenum type
Definition: qopengl.h:270
GLint GLint GLint GLint GLint x
[0]
GLenum mode
const GLfloat * m
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLsizei GLsizei GLfloat distance
GLenum target
GLbitfield flags
GLboolean enable
GLenum GLuint GLintptr offset
GLboolean GLboolean g
GLuint name
GLint y
struct _cl_event * event
Definition: qopenglext.h:2998
GLuint res
Definition: qopenglext.h:8867
GLuint in
Definition: qopenglext.h:8870
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
#define Q_ASSERT_X(cond, x, msg)
Definition: qrandom.cpp:85
SSL_CTX int(*) void arg)
QStyleSheetStyle * qt_styleSheet(QStyle *style)
#define emit
Definition: qtmetamacros.h:85
#define Q_TRACE(x,...)
Definition: qtrace_p.h:136
#define Q_TRACE_EXIT(x,...)
Definition: qtrace_p.h:137
#define leave(x)
Definition: qurlquery.cpp:243
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12216
#define QWIDGETSIZE_MAX
Definition: qwidget.h:951
QWidget * qobject_cast< QWidget * >(QObject *o)
Definition: qwidget.h:819
QT_BEGIN_NAMESPACE typedef QHash< WId, QWidget * > QWidgetMapper
Definition: qwindowdefs.h:104
QSet< QWidget * > QWidgetSet
Definition: qwindowdefs.h:105
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:81
#define enabled
Definition: qopenglext.h:3098
const char className[16]
[1]
Definition: qwizard.cpp:135
Q_UNUSED(salary)
[21]
QThreadPool pool
QTextStream out(stdout)
[7]
QList< QWidget * > widgets
[11]
QVBoxLayout * layout
QGraphicsOpacityEffect * effect
QGraphicsScene scene
[0]
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QSizePolicy policy
QStringList::Iterator it
QStringList list
[0]
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:165
const char * className() const
const QMetaObject * superClass() const
Definition: qobjectdefs.h:477
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent