Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Static Public Functions | Protected Functions | Properties | Friends | List of all members
QApplication Class Reference

The QApplication class manages the GUI application's control flow and main settings. More...

#include <qapplication.h>

Inheritance diagram for QApplication:
QCoreApplication QObject

Public Types

enum  ColorSpec { NormalColor =0, CustomColor =1, ManyColor =2 }
 See setColorSpec() for full details. More...
 
enum  Type { Tty, GuiClient, GuiServer }
 
- Public Types inherited from QCoreApplication
enum  { ApplicationFlags }
 
enum  Encoding { CodecForTr, UnicodeUTF8, DefaultCodec = CodecForTr }
 This enum type defines the 8-bit encoding of character string arguments to translate(): More...
 
typedef bool(* EventFilter) (void *message, long *result)
 A function with the following signature that can be used as an event filter: More...
 

Public Slots

static void aboutQt ()
 Displays a simple message box about Qt. More...
 
int autoMaximizeThreshold () const
 
bool autoSipEnabled () const
 
static void closeAllWindows ()
 Closes all top-level windows. More...
 
void setAutoMaximizeThreshold (const int threshold)
 
void setAutoSipEnabled (const bool enabled)
 
void setStyleSheet (const QString &sheet)
 
- Public Slots inherited from QCoreApplication
static void quit ()
 Tells the application to exit with return code 0 (success). More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void commitDataRequest (QSessionManager &sessionManager)
 This signal deals with Session Management{session management}. More...
 
void focusChanged (QWidget *old, QWidget *now)
 
void fontDatabaseChanged ()
 This signal is emitted when application fonts are loaded or removed. More...
 
void lastWindowClosed ()
 This signal is emitted from QApplication::exec() when the last visible primary window (i. More...
 
void saveStateRequest (QSessionManager &sessionManager)
 This signal deals with Session Management{session management}. More...
 
- Signals inherited from QCoreApplication
void aboutToQuit ()
 This signal is emitted when the application is about to quit the main event loop, e. More...
 
void unixSignal (int)
 This signal is emitted whenever a Unix signal is received by the application. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

virtual void commitData (QSessionManager &sm)
 This function deals with Session Management{session management}. More...
 
QInputContextinputContext () const
 Returns the QInputContext instance used by the application. More...
 
bool isSessionRestored () const
 Returns true if the application has been restored from an earlier Session Management{session}; otherwise returns false. More...
 
virtual bool macEventFilter (EventHandlerCallRef, EventRef)
 
bool notify (QObject *, QEvent *)
 Reimplemented Function More...
 
 QApplication (int &argc, char **argv)
 Initializes the window system and constructs an application object with argc command line arguments in argv. More...
 
 QApplication (int &argc, char **argv, bool GUIenabled)
 Constructs an application object with argc command line arguments in argv. More...
 
 QApplication (int &argc, char **argv, Type)
 Constructs an application object with argc command line arguments in argv. More...
 
 QApplication (Display *dpy, Qt::HANDLE visual=0, Qt::HANDLE cmap=0)
 Creates an application, given an already open display display. More...
 
 QApplication (Display *dpy, int &argc, char **argv, Qt::HANDLE visual=0, Qt::HANDLE cmap=0)
 Creates an application, given an already open display and using argc command line arguments in argv. More...
 
 QApplication (QApplication::QS60MainApplicationFactory factory, int &argc, char **argv)
 
virtual bool qwsEventFilter (QWSEvent *)
 This virtual function is only implemented under Qt for Embedded Linux. More...
 
int qwsProcessEvent (QWSEvent *)
 
void qwsSetCustomColors (QRgb *colortable, int start, int numColors)
 Set Qt for Embedded Linux custom color table. More...
 
virtual void saveState (QSessionManager &sm)
 This function deals with Session Management{session management}. More...
 
QString sessionId () const
 Returns the current Session Management{session's} identifier. More...
 
QString sessionKey () const
 Returns the session key in the current Session Management{session}. More...
 
void setInputContext (QInputContext *)
 This function replaces the QInputContext instance used by the application with inputContext. More...
 
QString styleSheet () const
 
void winFocus (QWidget *, bool)
 
virtual int x11ClientMessage (QWidget *, XEvent *, bool passive_only)
 
virtual bool x11EventFilter (XEvent *)
 
int x11ProcessEvent (XEvent *)
 This function does the core processing of individual X {event}s, normally by dispatching Qt events to the right destination. More...
 
virtual ~QApplication ()
 Cleans up any window system resources that were allocated by this application. More...
 
- Public Functions inherited from QCoreApplication
bool filterEvent (void *message, long *result)
 Sends message through the event filter that was set by setEventFilter(). More...
 
 QCoreApplication (int &argc, char **argv)
 Constructs a Qt kernel application. More...
 
EventFilter setEventFilter (EventFilter filter)
 Replaces the event filter function for the QCoreApplication with filter and returns the pointer to the replaced event filter function. More...
 
virtual bool winEventFilter (MSG *message, long *result)
 The message procedure calls this function for every message received. More...
 
 ~QCoreApplication ()
 Destroys the QCoreApplication object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QWidgetactiveModalWidget ()
 Returns the active modal widget. More...
 
static QWidgetactivePopupWidget ()
 Returns the active popup widget. More...
 
static QWidgetactiveWindow ()
 Returns the application top-level window that has the keyboard input focus, or 0 if no application window has the focus. More...
 
static void alert (QWidget *widget, int duration=0)
 
static QWidgetList allWidgets ()
 Returns a list of all the widgets in the application. More...
 
static void beep ()
 Sounds the bell, using the default volume and sound. More...
 
static void changeOverrideCursor (const QCursor &)
 Changes the currently active application override cursor to cursor. More...
 
static QClipboardclipboard ()
 Returns a pointer to the application global clipboard. More...
 
static int colorSpec ()
 Returns the color specification. More...
 
static int cursorFlashTime ()
 
static QDesktopWidgetdesktop ()
 Returns the desktop widget (also called the root window). More...
 
static bool desktopSettingsAware ()
 Returns true if Qt is set to use the system's standard colors, fonts, etc. More...
 
static int doubleClickInterval ()
 
static int exec ()
 Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called via quit()). More...
 
static QWidgetfocusWidget ()
 Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus. More...
 
static QFont font ()
 Returns the default application font. More...
 
static QFont font (const QWidget *)
 Returns the default font for the widget. More...
 
static QFont font (const char *className)
 Returns the font for widgets of the given className. More...
 
static QFontMetrics fontMetrics ()
 Returns display (screen) font metrics for the application font. More...
 
static QSize globalStrut ()
 
static bool isEffectEnabled (Qt::UIEffect)
 Returns true if effect is enabled; otherwise returns false. More...
 
static bool isLeftToRight ()
 Returns true if the application's layout direction is Qt::LeftToRight; otherwise returns false. More...
 
static bool isRightToLeft ()
 Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false. More...
 
static Qt::LayoutDirection keyboardInputDirection ()
 Returns the current keyboard input direction. More...
 
static int keyboardInputInterval ()
 
static QLocale keyboardInputLocale ()
 Returns the current keyboard input locale. More...
 
static Qt::KeyboardModifiers keyboardModifiers ()
 Returns the current state of the modifier keys on the keyboard. More...
 
static Qt::LayoutDirection layoutDirection ()
 
static Qt::MouseButtons mouseButtons ()
 Returns the current state of the buttons on the mouse. More...
 
static QCursoroverrideCursor ()
 Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the language used. More...
 
static QPalette palette ()
 Returns the application palette. More...
 
static QPalette palette (const QWidget *)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.If a widget is passed, the default palette for the widget's class is returned. More...
 
static QPalette palette (const char *className)
 Returns the palette for widgets of the given className. More...
 
static Qt::KeyboardModifiers queryKeyboardModifiers ()
 Queries and returns the state of the modifier keys on the keyboard. More...
 
static bool quitOnLastWindowClosed ()
 
static void restoreOverrideCursor ()
 Undoes the last setOverrideCursor(). More...
 
static void setActiveWindow (QWidget *act)
 Sets the active window to the active widget in response to a system event. More...
 
static void setColorSpec (int)
 Sets the color specification for the application to spec. More...
 
static void setCursorFlashTime (int)
 
static void setDesktopSettingsAware (bool)
 Sets whether Qt should use the system's standard colors, fonts, etc., to on. More...
 
static void setDoubleClickInterval (int)
 
static void setEffectEnabled (Qt::UIEffect, bool enable=true)
 Enables the UI effect effect if enable is true, otherwise the effect will not be used. More...
 
static void setFont (const QFont &, const char *className=0)
 Changes the default application font to font. More...
 
static void setGlobalStrut (const QSize &)
 
static void setGraphicsSystem (const QString &)
 Sets the default graphics backend to system, which will be used for on-screen widgets and QPixmaps. More...
 
static void setKeyboardInputInterval (int)
 
static void setLayoutDirection (Qt::LayoutDirection direction)
 
static void setOverrideCursor (const QCursor &)
 Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is false). More...
 
static void setPalette (const QPalette &, const char *className=0)
 Changes the default application palette to palette. More...
 
static void setQuitOnLastWindowClosed (bool quit)
 
static void setStartDragDistance (int l)
 
static void setStartDragTime (int ms)
 
static void setStyle (QStyle *)
 Sets the application's GUI style to style. More...
 
static QStylesetStyle (const QString &)
 Requests a QStyle object for style from the QStyleFactory. More...
 
static void setWheelScrollLines (int)
 
static void setWindowIcon (const QIcon &icon)
 
static int startDragDistance ()
 
static int startDragTime ()
 
static QStylestyle ()
 Returns the application's style object. More...
 
static void syncX ()
 Synchronizes with the X server in the X11 implementation. More...
 
static QWidgettopLevelAt (const QPoint &p)
 Returns the top-level widget at the given point; returns 0 if there is no such widget. More...
 
static QWidgettopLevelAt (int x, int y)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the top-level widget at the point ({x}, {y}); returns 0 if there is no such widget. More...
 
static QWidgetList topLevelWidgets ()
 Returns a list of the top-level widgets (windows) in the application. More...
 
static Type type ()
 Returns the type of application (Tty , GuiClient, or GuiServer). More...
 
static int wheelScrollLines ()
 
static QWidgetwidgetAt (const QPoint &p)
 Returns the widget at global screen position point, or 0 if there is no Qt widget there. More...
 
static QWidgetwidgetAt (int x, int y)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the widget at global screen position (x, y), or 0 if there is no Qt widget there. More...
 
static QIcon windowIcon ()
 
static void winMouseButtonUp ()
 
- Static Public Functions inherited from QCoreApplication
static void addLibraryPath (const QString &)
 Prepends path to the beginning of the library path list, ensuring that it is searched for libraries first. More...
 
static QString applicationDirPath ()
 Returns the directory that contains the application executable. More...
 
static QString applicationFilePath ()
 Returns the file path of the application executable. More...
 
static QString applicationName ()
 
static qint64 applicationPid ()
 Returns the current process ID for the application. More...
 
static QString applicationVersion ()
 
static QT_DEPRECATED int argc ()
 Use arguments(). More...
 
static QStringList arguments ()
 Returns the list of command-line arguments. More...
 
static QT_DEPRECATED char ** argv ()
 Use arguments() instead. More...
 
static bool closingDown ()
 Returns true if the application objects are being destroyed; otherwise returns false. More...
 
static int exec ()
 Enters the main event loop and waits until exit() is called. More...
 
static void exit (int retcode=0)
 Tells the application to exit with a return code. More...
 
static void flush ()
 Flushes the platform specific event queues. More...
 
static bool hasPendingEvents ()
 This function returns true if there are pending events; otherwise returns false. More...
 
static void installTranslator (QTranslator *messageFile)
 Adds the translation file translationFile to the list of translation files to be used for translations. More...
 
static QCoreApplicationinstance ()
 Returns a pointer to the application's QCoreApplication (or QApplication) instance. More...
 
static QStringList libraryPaths ()
 Returns a list of paths that the application will search when dynamically loading libraries. More...
 
static QString organizationDomain ()
 
static QString organizationName ()
 
static void postEvent (QObject *receiver, QEvent *event)
 Adds the event event, with the object receiver as the receiver of the event, to an event queue and returns immediately. More...
 
static void postEvent (QObject *receiver, QEvent *event, int priority)
 
static void processEvents (QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
 Processes all pending events for the calling thread according to the specified flags until there are no more events to process. More...
 
static void processEvents (QEventLoop::ProcessEventsFlags flags, int maxtime)
 
static void removeLibraryPath (const QString &)
 Removes path from the library path list. More...
 
static void removePostedEvents (QObject *receiver)
 Removes all events posted using postEvent() for receiver. More...
 
static void removePostedEvents (QObject *receiver, int eventType)
 
static void removeTranslator (QTranslator *messageFile)
 Removes the translation file translationFile from the list of translation files used by this application. More...
 
static bool sendEvent (QObject *receiver, QEvent *event)
 Sends event event directly to receiver receiver, using the notify() function. More...
 
static void sendPostedEvents (QObject *receiver, int event_type)
 Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent() and which are for the object receiver and have the event type event_type. More...
 
static void sendPostedEvents ()
 
static void setApplicationName (const QString &application)
 
static void setApplicationVersion (const QString &version)
 
static void setAttribute (Qt::ApplicationAttribute attribute, bool on=true)
 Sets the attribute attribute if on is true; otherwise clears the attribute. More...
 
static void setLibraryPaths (const QStringList &)
 Sets the list of directories to search when loading libraries to paths. More...
 
static void setOrganizationDomain (const QString &orgDomain)
 
static void setOrganizationName (const QString &orgName)
 
static bool startingUp ()
 Returns true if an application object has not been created yet; otherwise returns false. More...
 
static bool testAttribute (Qt::ApplicationAttribute attribute)
 Returns true if attribute attribute is set; otherwise returns false. More...
 
static QString translate (const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
 
static QString translate (const char *context, const char *key, const char *disambiguation, Encoding encoding, int n)
 Returns the translation text for sourceText, by querying the installed translation files. More...
 
static void watchUnixSignal (int signal, bool watch)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Protected Functions

bool compressEvent (QEvent *, QObject *receiver, QPostEventList *)
 
bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
void setArgs (int, char **)
 
- Protected Functions inherited from QCoreApplication
 QCoreApplication (QCoreApplicationPrivate &p)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Properties

int autoMaximizeThreshold
 defines a threshold for auto maximizing widgets More...
 
bool autoSipEnabled
 toggles automatic SIP (software input panel) visibility More...
 
int cursorFlashTime
 the text cursor's flash (blink) time in milliseconds More...
 
int doubleClickInterval
 the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks More...
 
QSize globalStrut
 the minimum size that any GUI element that the user can interact with should have More...
 
int keyboardInputInterval
 the time limit in milliseconds that distinguishes a key press from two consecutive key presses More...
 
Qt::LayoutDirection layoutDirection
 the default layout direction for this application More...
 
bool quitOnLastWindowClosed
 whether the application implicitly quits when the last window is closed. More...
 
int startDragDistance
 If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required. More...
 
int startDragTime
 the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin More...
 
QString styleSheet
 the application style sheet More...
 
int wheelScrollLines
 the number of lines to scroll a widget, when the mouse wheel is rotated. More...
 
QIcon windowIcon
 the default window icon More...
 

Friends

class Q3AccelManager
 
class QAction
 
class QDirectPainter
 
class QDirectPainterPrivate
 
class QETWidget
 
class QFontDatabasePrivate
 
class QGestureManager
 
class QGraphicsItem
 
class QGraphicsScene
 
class QGraphicsScenePrivate
 
class QGraphicsWidget
 
class QInputContext
 
class QLineEdit
 
class QShortcut
 
class QTextControl
 
class QTranslator
 
class QWidget
 
class QWidgetAnimator
 
class QWidgetPrivate
 
class QWSDirectPainterSurface
 

Additional Inherited Members

- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QApplication class manages the GUI application's control flow and main settings.

QApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization, finalization, and provides session management. In addition, QApplication handles most of the system-wide and application-wide settings.

For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the QtGui library.

The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer.

QApplication's main areas of responsibility are:

Since the QApplication object does so much initialization, it must be created before any other objects related to the user interface are created. QApplication also deals with common command line arguments. Hence, it is usually a good idea to create it before any interpretation or modification of argv is done in the application itself.

Groups of functions

System settings

desktopSettingsAware(), setDesktopSettingsAware(), cursorFlashTime(), setCursorFlashTime(), doubleClickInterval(), setDoubleClickInterval(), setKeyboardInputInterval(), wheelScrollLines(), setWheelScrollLines(), palette(), setPalette(), font(), setFont(), fontMetrics().

Event handling

exec(), processEvents(), exit(), quit(). sendEvent(), postEvent(), sendPostedEvents(), removePostedEvents(), hasPendingEvents(), notify(), macEventFilter(), qwsEventFilter(), x11EventFilter(), x11ProcessEvent(), winEventFilter().

GUI Styles

style(), setStyle().

Color usage

colorSpec(), setColorSpec(), qwsSetCustomColors().

Text handling

installTranslator(), removeTranslator() translate().

Widgets

allWidgets(), topLevelWidgets(), desktop(), activePopupWidget(), activeModalWidget(), clipboard(), focusWidget(), activeWindow(), widgetAt().

Advanced cursor handling

overrideCursor(), setOverrideCursor(), restoreOverrideCursor().

X Window System synchronization

flushX(), syncX().

Session management

isSessionRestored(), sessionId(), commitData(), saveState().

Miscellaneous closeAllWindows(), startingUp(), closingDown(), type().
See also
QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings

Definition at line 99 of file qapplication.h.

Enumerations

◆ ColorSpec

See setColorSpec() for full details.

  • NormalColor the default color allocation policy
  • CustomColor the same as NormalColor for X11; allocates colors to a palette on demand under Windows
  • ManyColor the right choice for applications that use thousands of colors
Enumerator
NormalColor 
CustomColor 
ManyColor 

Definition at line 148 of file qapplication.h.

◆ Type

  • Tty a console application
  • GuiClient a GUI client application
  • GuiServer a GUI server application (for Qt for Embedded Linux)
Enumerator
Tty 
GuiClient 
GuiServer 

Definition at line 123 of file qapplication.h.

Constructors and Destructors

◆ ~QApplication()

QApplication::~QApplication ( )
virtual

Cleans up any window system resources that were allocated by this application.

Sets the global variable qApp to 0.

Definition at line 1105 of file qapplication.cpp.

1106 {
1107  Q_D(QApplication);
1108 
1109 #ifndef QT_NO_CLIPBOARD
1110  // flush clipboard contents
1111  if (qt_clipboard) {
1114  }
1115 #endif
1116 
1117  //### this should probable be done even later
1119 
1120  // kill timers before closing down the dispatcher
1121  d->toolTipWakeUp.stop();
1122  d->toolTipFallAsleep.stop();
1123 
1124  d->eventDispatcher->closingDown();
1125  d->eventDispatcher = 0;
1128 
1129  delete QWidgetPrivate::mapper;
1131 
1132  // delete all widgets
1136  for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
1137  register QWidget *w = *it;
1138  if (!w->parent()) // window
1139  w->destroy(true, true);
1140  }
1141  delete mySet;
1142  }
1143 
1144  delete qt_desktopWidget;
1145  qt_desktopWidget = 0;
1146 
1147 #ifndef QT_NO_CLIPBOARD
1148  delete qt_clipboard;
1149  qt_clipboard = 0;
1150 #endif
1151 
1152 #if defined(Q_WS_X11) || defined(Q_WS_WIN)
1153  delete d->move_cursor; d->move_cursor = 0;
1154  delete d->copy_cursor; d->copy_cursor = 0;
1155  delete d->link_cursor; d->link_cursor = 0;
1156 #endif
1157 #if defined(Q_WS_WIN)
1158  delete d->ignore_cursor; d->ignore_cursor = 0;
1159 #endif
1160 
1167  app_palettes()->clear();
1168 
1169  {
1170  QMutexLocker locker(applicationFontMutex());
1173  }
1178  app_fonts()->clear();
1179 
1186 #ifndef QT_NO_CURSOR
1187  d->cursor_list.clear();
1188 #endif
1189 
1190 #ifndef QT_NO_DRAGANDDROP
1191  if (qt_is_gui_used)
1192  delete QDragManager::self();
1193 #endif
1194 
1195  d->cleanupMultitouch();
1196 
1197  qt_cleanup();
1198 
1200  qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
1201 #ifndef QT_NO_SESSIONMANAGER
1202  delete d->session_manager;
1203  d->session_manager = 0;
1204 #endif //QT_NO_SESSIONMANAGER
1205 
1210 
1211  drag_time = 500;
1212  drag_distance = 4;
1222 
1223 #ifndef QT_NO_STATEMACHINE
1224  // trigger unregistering of QStateMachine's GUI types
1226 #endif
1227  // trigger unregistering of QVariant's GUI types
1229 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
int qUnregisterGuiVariant()
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
static bool fade_tooltip
#define it(className, varName)
static QSize app_strut
static QPalette * set_pal
const_iterator constEnd() const
Definition: qset.h:171
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QClipboard * qt_clipboard
static bool animate_ui
#define Q_D(Class)
Definition: qglobal.h:2482
static QPalette * app_pal
static QFont * sys_font
Q_CORE_EXPORT void qt_call_post_routines()
static int keyboard_input_time
Q_CORE_EXPORT void qDebug(const char *,...)
QDesktopWidget * qt_desktopWidget
void destroy(bool destroyWindow=true, bool destroySubWindows=true)
Frees up window system resources.
static Qt::LayoutDirection layout_direction
static QIcon * app_icon
static int mouse_double_click_time
const_iterator ConstIterator
Definition: qset.h:177
static bool animate_combo
static QStyle * app_style
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QPalette * sys_pal
static QWidgetSet * allWidgets
Definition: qwidget_p.h:715
static QFont * app_font
static QDragManager * self()
Definition: qdnd.cpp:163
static bool animate_tooltip
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static bool obey_desktop_settings
int qUnregisterGuiStateMachine()
static int drag_distance
void qt_cleanup()
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
static QGraphicsSystem * graphics_system
const_iterator constBegin() const
Definition: qset.h:168
static QWidgetMapper * mapper
Definition: qwidget_p.h:714
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
bool qt_is_gui_used
static QFont * set_font
static bool widgetCount
static int instanceCounter
Definition: qwidget_p.h:752
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
static int drag_time
static bool animate_menu
static int cursor_flash_time
static int maxInstances
Definition: qwidget_p.h:753

◆ QApplication() [1/6]

QApplication::QApplication ( int &  argc,
char **  argv 
)

Initializes the window system and constructs an application object with argc command line arguments in argv.

Warning
The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.

The global qApp pointer refers to this application object. Only one application object should be created.

This application object must be constructed before any paint devices (including widgets, pixmaps, bitmaps etc.).

Note
argc and argv might be changed as Qt removes command line arguments that it recognizes.

Qt debugging options (not available if Qt was compiled without the QT_DEBUG flag defined):

  • -nograb, tells Qt that it must never grab the mouse or the keyboard.
  • -dograb (only under X11), running under a debugger can cause an implicit -nograb, use -dograb to override.
  • -sync (only under X11), switches to synchronous mode for debugging.

See Debugging Techniques for a more detailed explanation.

All Qt programs automatically support the following command line options:

  • -style= style, sets the application GUI style. Possible values are motif, windows, and platinum. If you compiled Qt with additional styles or have additional styles as plugins these will be available to the -style command line option.
  • -style style, is the same as listed above.
  • -stylesheet= stylesheet, sets the application styleSheet . The value must be a path to a file that contains the Style Sheet.
    Note
    Relative URLs in the Style Sheet file are relative to the Style Sheet file's path.
  • -stylesheet stylesheet, is the same as listed above.
  • -session= session, restores the application from an earlier Session Management{session}.
  • -session session, is the same as listed above.
  • -widgetcount, prints debug message at the end about number of widgets left undestroyed and maximum number of widgets existed at the same time
  • -reverse, sets the application's layout direction to Qt::RightToLeft
  • -graphicssystem, sets the backend to be used for on-screen widgets and QPixmaps. Available options are raster and opengl.
  • -qmljsdebugger=, activates the QML/JS debugger with a specified port. The value must be of format port:1234[,block], where block is optional and will make the application wait until a debugger connects to it.

The X11 version of Qt supports some traditional X11 command line options:

  • -display display, sets the X display (default is $DISPLAY).
  • -geometry geometry, sets the client geometry of the first window that is shown.
  • -fn or -font font, defines the application font. The font should be specified using an X logical font description. Note that this option is ignored when Qt is built with fontconfig support enabled.
  • -bg or -background color, sets the default background color and an application palette (light and dark shades are calculated).
  • -fg or -foreground color, sets the default foreground color.
  • -btn or -button color, sets the default button color.
  • -name name, sets the application name.
  • -title title, sets the application title.
  • -visual TrueColor, forces the application to use a TrueColor visual on an 8-bit display.
  • -ncols count, limits the number of colors allocated in the color cube on an 8-bit display, if the application is using the QApplication::ManyColor color specification. If count is 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, and 6 of blue); for other values, a cube approximately proportional to a 2x3x1 cube is used.
  • -cmap, causes the application to install a private color map on an 8-bit display.
  • -im, sets the input method server (equivalent to setting the XMODIFIERS environment variable)
  • -inputstyle, defines how the input is inserted into the given widget, e.g., onTheSpot makes the input appear directly in the widget, while overTheSpot makes the input appear in a box floating over the widget and is not inserted until the editing is done.

X11 Notes

If QApplication fails to open the X11 display, it will terminate the process. This behavior is consistent with most X11 applications.

See also
arguments()

Definition at line 739 of file qapplication.cpp.

Referenced by QApplication().

741 { Q_D(QApplication); d->construct(); }
double d
Definition: qnumeric_p.h:62
static QT_DEPRECATED int argc()
Use arguments().
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QT_DEPRECATED char ** argv()
Use arguments() instead.
#define Q_D(Class)
Definition: qglobal.h:2482
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
friend class QApplicationPrivate

◆ QApplication() [2/6]

QApplication::QApplication ( int &  argc,
char **  argv,
bool  GUIenabled 
)

Constructs an application object with argc command line arguments in argv.

If GUIenabled is true, a GUI application is constructed, otherwise a non-GUI (console) application is created.

Warning
The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.

Set GUIenabled to false for programs without a graphical user interface that should be able to run without a window system.

On X11, the window system is initialized if GUIenabled is true. If GUIenabled is false, the application does not connect to the X server. On Windows and Mac OS, currently the window system is always initialized, regardless of the value of GUIenabled. This may change in future versions of Qt.

The following example shows how to create an application that uses a graphical interface when available.

int main(int argc, char **argv)
{
#ifdef Q_WS_X11
bool useGUI = getenv("DISPLAY") != 0;
#else
bool useGUI = true;
#endif
QApplication app(argc, argv, useGUI);
if (useGUI) {
// start GUI version
...
} else {
// start non-GUI version
...
}
return app.exec();
}

Definition at line 773 of file qapplication.cpp.

774  : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
775 { Q_D(QApplication); d->construct(); }
double d
Definition: qnumeric_p.h:62
static QT_DEPRECATED int argc()
Use arguments().
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QT_DEPRECATED char ** argv()
Use arguments() instead.
#define Q_D(Class)
Definition: qglobal.h:2482
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
friend class QApplicationPrivate

◆ QApplication() [3/6]

QApplication::QApplication ( int &  argc,
char **  argv,
Type  type 
)

Constructs an application object with argc command line arguments in argv.

Warning
The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.

With Qt for Embedded Linux, passing QApplication::GuiServer for type makes this application the server (equivalent to running with the -qws option).

Definition at line 796 of file qapplication.cpp.

797  : QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
798 { Q_D(QApplication); d->construct(); }
double d
Definition: qnumeric_p.h:62
static QT_DEPRECATED int argc()
Use arguments().
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QT_DEPRECATED char ** argv()
Use arguments() instead.
#define Q_D(Class)
Definition: qglobal.h:2482
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
friend class QApplicationPrivate
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).

◆ QApplication() [4/6]

QApplication::QApplication ( Display display,
Qt::HANDLE  visual = 0,
Qt::HANDLE  colormap = 0 
)

Creates an application, given an already open display display.

If visual and colormap are non-zero, the application will use those values as the default Visual and Colormap contexts.

Warning
Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.

This function is only available on X11.

Definition at line 911 of file qapplication.cpp.

913 {
914  if (! dpy)
915  qWarning("QApplication: Invalid Display* argument");
916  Q_D(QApplication);
917  d->construct(dpy, visual, colormap);
918 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
#define Q_D(Class)
Definition: qglobal.h:2482
static char * aargv[]
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
Q_CORE_EXPORT void qWarning(const char *,...)
friend class QApplicationPrivate
static int aargc

◆ QApplication() [5/6]

QApplication::QApplication ( Display display,
int &  argc,
char **  argv,
Qt::HANDLE  visual = 0,
Qt::HANDLE  colormap = 0 
)

Creates an application, given an already open display and using argc command line arguments in argv.

If visual and colormap are non-zero, the application will use those values as the default Visual and Colormap contexts.

Warning
Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.

This function is only available on X11.

Definition at line 944 of file qapplication.cpp.

947 {
948  if (! dpy)
949  qWarning("QApplication: Invalid Display* argument");
950  Q_D(QApplication);
951  d->construct(dpy, visual, colormap);
952 }
double d
Definition: qnumeric_p.h:62
static QT_DEPRECATED int argc()
Use arguments().
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QT_DEPRECATED char ** argv()
Use arguments() instead.
#define Q_D(Class)
Definition: qglobal.h:2482
QCoreApplication(int &argc, char **argv)
Constructs a Qt kernel application.
Q_CORE_EXPORT void qWarning(const char *,...)
friend class QApplicationPrivate

◆ QApplication() [6/6]

QApplication::QApplication ( QApplication::QS60MainApplicationFactory  factory,
int &  argc,
char **  argv 
)

Functions

◆ aboutQt

void QApplication::aboutQt ( )
staticslot

Displays a simple message box about Qt.

The message includes the version number of Qt being used by the application.

This is useful for inclusion in the Help menu of an application, as shown in the Menus example.

This function is a convenience slot for QMessageBox::aboutQt().

Definition at line 2400 of file qapplication.cpp.

2401 {
2402 #ifndef QT_NO_MESSAGEBOX
2404 #ifdef Q_WS_MAC
2405  0
2406 #else
2407  activeWindow()
2408 #endif // Q_WS_MAC
2409  );
2410 #endif // QT_NO_MESSAGEBOX
2411 }
static void aboutQt(QWidget *parent, const QString &title=QString())
Displays a simple message box about Qt, with the given title and centered over parent (if parent is n...
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...

◆ activeModalWidget()

QWidget * QApplication::activeModalWidget ( )
static

Returns the active modal widget.

A modal widget is a special top-level widget which is a subclass of QDialog that specifies the modal parameter of the constructor as true. A modal widget must be closed before the user can continue with other parts of the program.

Modal widgets are organized in a stack. This function returns the active modal widget at the top of the stack.

See also
activePopupWidget(), topLevelWidgets()

Definition at line 1095 of file qapplication.cpp.

Referenced by closeAllWindows(), QApplicationPrivate::dispatchEnterLeave(), QWidget::event(), QAxServerBase::eventFilter(), QApplicationPrivate::globalEventProcessor(), qt_mac_mouse_inside_answer_rect(), qwsProcessEvent(), QSoftKeyManager::softkeySource(), QApplicationPrivate::tryModalHelper(), QGraphicsView::viewportEvent(), and QAxClientSite::windowActivationChange().

1096 {
1097  return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0;
1098 }
QWidgetList * qt_modal_stack
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282

◆ activePopupWidget()

QWidget * QApplication::activePopupWidget ( )
static

Returns the active popup widget.

A popup widget is a special top-level widget that sets the Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application opens a popup widget, all events are sent to the popup. Normal widgets and modal widgets cannot be accessed before the popup widget is closed.

Only other popup widgets may be opened when a popup widget is shown. The popup widgets are organized in a stack. This function returns the active popup widget at the top of the stack.

See also
activeModalWidget(), topLevelWidgets()

Definition at line 1074 of file qapplication.cpp.

Referenced by QMenuPrivate::activateAction(), QShortcutMap::correctContext(), QApplicationPrivate::dispatchEnterLeave(), QToolBar::event(), QWidget::event(), QWidgetResizeHandler::eventFilter(), flipPoint(), QLineEdit::focusOutEvent(), QApplicationPrivate::globalEventProcessor(), QApplicationPrivate::isBlockedByModal(), QWidget::mousePressEvent(), notify(), QApplicationPrivate::notify_helper(), onApplicationChangedActivation(), qt_mac_handleTabletEvent(), QtWndProc(), qwsProcessEvent(), QTest::sendKeyEvent(), QApplicationPrivate::sendMouseEvent(), QWidgetPrivate::show_helper(), QSoftKeyManager::softkeySource(), QETWidget::translateMouseEvent(), QETWidget::translateWheelEvent(), QApplicationPrivate::tryModalHelper(), QGraphicsView::viewportEvent(), and x11ProcessEvent().

1075 {
1078 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static QWidgetList * popupWidgets
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284

◆ activeWindow()

QWidget * QApplication::activeWindow ( )
static

◆ alert()

void QApplication::alert ( QWidget widget,
int  msec = 0 
)
static
Since
4.3

Causes an alert to be shown for widget if the window is not the active window. The alert is shown for msec miliseconds. If msec is zero (the default), then the alert is shown indefinitely until the window becomes active again.

Currently this function does nothing on Qt for Embedded Linux.

On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock.

On Windows, this causes the window's taskbar entry to flash for a time. If msec is zero, the flashing will stop and the taskbar entry will turn a different color (currently orange).

On X11, this will cause the window to be marked as "demands attention", the window must not be hidden (i.e. not have hide() called on it, but be visible in some sort of way) in order for this to work.

Definition at line 2741 of file qapplication_mac.mm.

Referenced by alert_widget(), parseGeometry(), and syncX().

2742 {
2743  if (!QApplicationPrivate::checkInstance("alert"))
2744  return;
2745 
2746  QWidgetList windowsToMark;
2747  if (!widget)
2748  windowsToMark += topLevelWidgets();
2749  else
2750  windowsToMark.append(widget->window());
2751 
2752  bool needNotification = false;
2753  for (int i = 0; i < windowsToMark.size(); ++i) {
2754  QWidget *window = windowsToMark.at(i);
2755  if (!window->isActiveWindow() && window->isVisible()) {
2756  needNotification = true; // yeah, we may set it multiple times, but that's OK.
2757  if (duration != 0) {
2758  QTimer *timer = new QTimer(qApp);
2759  timer->setSingleShot(true);
2760  connect(timer, SIGNAL(timeout()), qApp, SLOT(_q_alertTimeOut()));
2761  if (QTimer *oldTimer = qApp->d_func()->alertTimerHash.value(widget)) {
2762  qApp->d_func()->alertTimerHash.remove(widget);
2763  delete oldTimer;
2764  }
2765  qApp->d_func()->alertTimerHash.insert(widget, timer);
2766  timer->start(duration);
2767  }
2768  }
2769  }
2770  if (needNotification)
2772 }
void setSingleShot(bool singleShot)
Definition: qtimer.h:108
static bool checkInstance(const char *method)
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
void qt_mac_send_notification()
bool isVisible() const
Definition: qwidget.h:1005
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
EventLoopTimerRef timer
#define SIGNAL(a)
Definition: qobjectdefs.h:227
NSWindow * window
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition: qtimer.cpp:249
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ allWidgets()

QWidgetList QApplication::allWidgets ( )
static

Returns a list of all the widgets in the application.

The list is empty (QList::isEmpty()) if there are no widgets.

Note
Some of the widgets may be hidden.

Example:

void updateAllWidgets()
{
foreach (QWidget *widget, QApplication::allWidgets())
widget->update();
}
See also
topLevelWidgets(), QWidget::isVisible()

Definition at line 2214 of file qapplication.cpp.

Referenced by QWidgetPrivate::frameStrut(), setFont(), QApplicationPrivate::setPalette_helper(), setStyle(), setWindowIcon(), topLevelWidgets(), update_toolbar_style(), and QGtkStyleUpdateScheduler::updateTheme().

2215 {
2218  return QWidgetList();
2219 }
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
QList< T > toList() const
Definition: qset.h:296
static QWidgetSet * allWidgets
Definition: qwidget_p.h:715

◆ autoMaximizeThreshold

int QApplication::autoMaximizeThreshold ( ) const
slot

◆ autoSipEnabled

bool QApplication::autoSipEnabled ( ) const
slot

Referenced by setAutoSipEnabled().

◆ beep()

void QApplication::beep ( )
static

Sounds the bell, using the default volume and sound.

The function is not available in Qt for Embedded Linux.

Definition at line 2736 of file qapplication_mac.mm.

Referenced by QApplicationPrivate::globalAppleEventProcessor(), QApplicationPrivate::globalEventProcessor(), QKeyMapperPrivate::isADeadKey(), QMenu::keyPressEvent(), parseGeometry(), qt_try_modal(), qt_win_getKeyboardModifiers(), and syncX().

2737 {
2738  qt_mac_beep();
2739 }
void qt_mac_beep()
Definition: qsound_mac.mm:53

◆ changeOverrideCursor()

void QApplication::changeOverrideCursor ( const QCursor cursor)
static

Changes the currently active application override cursor to cursor.

This function has no effect if setOverrideCursor() was not called.

See also
setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), QWidget::setCursor()

Definition at line 3868 of file qapplication.cpp.

Referenced by QWhatsThisPrivate::eventFilter().

3869 {
3870  if (qApp->d_func()->cursor_list.isEmpty())
3871  return;
3872  qApp->d_func()->cursor_list.removeFirst();
3873  setOverrideCursor(cursor);
3874 }
#define qApp
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...

◆ clipboard()

QClipboard * QApplication::clipboard ( )
static

Returns a pointer to the application global clipboard.

Note
The QApplication object should already be constructed before accessing the clipboard.

Definition at line 3336 of file qapplication.cpp.

Referenced by QTextControlPrivate::_q_copyLink(), QTextControl::canPaste(), QX11Data::clipboardWaitForEvent(), QLineControl::copy(), QTextControl::copy(), QmlJSDebugger::ToolBarColorBox::copyColorToClipboard(), QAccessibleTextWidget::copyText(), QAccessibleSimpleEditableTextInterface::copyText(), QLineEdit::createStandardContextMenu(), QAccessibleTextWidget::cutText(), QAccessibleSimpleEditableTextInterface::cutText(), QPlatformClipboard::emitChanged(), QDeclarativeTextEditPrivate::init(), QDeclarativeTextInputPrivate::init(), QMessageBox::keyPressEvent(), QAbstractItemView::keyPressEvent(), QTextControlPrivate::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QLineControl::paste(), QTextControl::paste(), QAccessibleTextWidget::pasteText(), QAccessibleSimpleEditableTextInterface::pasteText(), QLineControl::processMouseEvent(), QDeclarativeTextInput::q_canPasteChanged(), QClipboardINCRTransaction::QClipboardINCRTransaction(), qt_check_clipboard_sentinel(), qt_check_selection_sentinel(), QTextControlPrivate::setClipboardSelection(), and QClipboardINCRTransaction::x11Event().

3337 {
3338  if (qt_clipboard == 0) {
3339  if (!qApp) {
3340  qWarning("QApplication: Must construct a QApplication before accessing a QClipboard");
3341  return 0;
3342  }
3343  qt_clipboard = new QClipboard(0);
3344  }
3345  return qt_clipboard;
3346 }
QClipboard * qt_clipboard
#define qApp
Q_CORE_EXPORT void qWarning(const char *,...)
The QClipboard class provides access to the window system clipboard.
Definition: qclipboard.h:62

◆ closeAllWindows

void QApplication::closeAllWindows ( )
staticslot

Closes all top-level windows.

This function is particularly useful for applications with many top-level windows. It could, for example, be connected to a Exit entry in the File menu:

exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));

The windows are closed in random order, until one window does not accept the close event. The application quits when the last window was successfully closed; this can be turned off by setting quitOnLastWindowClosed to false.

See also
quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(), QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(), QWidget::isWindow()

Definition at line 2369 of file qapplication.cpp.

Referenced by event().

2370 {
2371  bool did_close = true;
2372  QWidget *w;
2373  while ((w = activeModalWidget()) && did_close) {
2374  if (!w->isVisible() || w->data->is_closing)
2375  break;
2376  did_close = w->close();
2377  }
2379  for (int i = 0; did_close && i < list.size(); ++i) {
2380  w = list.at(i);
2381  if (w->isVisible()
2382  && w->windowType() != Qt::Desktop
2383  && !w->data->is_closing) {
2384  did_close = w->close();
2386  i = -1;
2387  }
2388  }
2389 }
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QWidget * activeModalWidget()
Returns the active modal widget.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QWidgetData * data
Definition: qwidget.h:815
uint is_closing
Definition: qwidget.h:123
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ colorSpec()

int QApplication::colorSpec ( )
static

Returns the color specification.

See also
QApplication::setColorSpec()

Definition at line 1706 of file qapplication.cpp.

1707 {
1709 }

◆ commitData()

void QApplication::commitData ( QSessionManager manager)
virtual

This function deals with Session Management{session management}.

It is invoked when the QSessionManager wants the application to commit all its data.

Usually this means saving all open files, after getting permission from the user. Furthermore you may want to provide a means by which the user can cancel the shutdown.

You should not exit the application within this function. Instead, the session manager may or may not do this afterwards, depending on the context.

Warning
Within this function, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details and example usage.

The default implementation requests interaction and sends a close event to all visible top-level widgets. If any event was rejected, the shutdown is canceled.

See also
isSessionRestored(), sessionId(), saveState(), {Session Management}

Definition at line 3592 of file qapplication.cpp.

3593 {
3594  emit commitDataRequest(manager);
3595  if (manager.allowsInteraction()) {
3596  QWidgetList done;
3598  bool cancelled = false;
3599  for (int i = 0; !cancelled && i < list.size(); ++i) {
3600  QWidget* w = list.at(i);
3601  if (w->isVisible() && !done.contains(w)) {
3602  cancelled = !w->close();
3603  if (!cancelled)
3604  done.append(w);
3606  i = -1;
3607  }
3608  }
3609  if (cancelled)
3610  manager.cancel();
3611  }
3612 }
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool allowsInteraction()
Asks the session manager for permission to interact with the user.
void commitDataRequest(QSessionManager &sessionManager)
This signal deals with Session Management{session management}.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
void cancel()
Tells the session manager to cancel the shutdown process.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ commitDataRequest

void QApplication::commitDataRequest ( QSessionManager manager)
signal

This signal deals with Session Management{session management}.

Since
4.2

It is emitted when the QSessionManager wants the application to commit all its data.

Usually this means saving all open files, after getting permission from the user. Furthermore you may want to provide a means by which the user can cancel the shutdown.

You should not exit the application within this signal. Instead, the session manager may or may not do this afterwards, depending on the context.

Warning
Within this signal, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details and example usage.
Note
You should use Qt::DirectConnection when connecting to this signal.
See also
isSessionRestored(), sessionId(), saveState(), {Session Management}

Referenced by commitData().

◆ compressEvent()

bool QApplication::compressEvent ( QEvent event,
QObject receiver,
QPostEventList postedEvents 
)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QCoreApplication.

Definition at line 1298 of file qapplication.cpp.

1299 {
1300  if ((event->type() == QEvent::UpdateRequest
1301 #ifdef QT3_SUPPORT
1302  || event->type() == QEvent::LayoutHint
1303 #endif
1304  || event->type() == QEvent::LayoutRequest
1305  || event->type() == QEvent::Resize
1306  || event->type() == QEvent::Move
1307  || event->type() == QEvent::LanguageChange
1308  || event->type() == QEvent::UpdateSoftKeys
1309  || event->type() == QEvent::InputMethod)) {
1310  for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
1311  const QPostEvent &cur = *it;
1312  if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
1313  continue;
1314  if (cur.event->type() == QEvent::LayoutRequest
1315 #ifdef QT3_SUPPORT
1316  || cur.event->type() == QEvent::LayoutHint
1317 #endif
1318  || cur.event->type() == QEvent::UpdateRequest) {
1319  ;
1320  } else if (cur.event->type() == QEvent::Resize) {
1321  ((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s;
1322  } else if (cur.event->type() == QEvent::Move) {
1323  ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
1324  } else if (cur.event->type() == QEvent::LanguageChange) {
1325  ;
1326  } else if (cur.event->type() == QEvent::UpdateSoftKeys) {
1327  ;
1328  } else if ( cur.event->type() == QEvent::InputMethod ) {
1329  *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
1330  } else {
1331  continue;
1332  }
1333  delete event;
1334  return true;
1335  }
1336  return false;
1337  }
1338  return QCoreApplication::compressEvent(event, receiver, postedEvents);
1339 }
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *)
Returns true if event was compressed away (possibly deleted) and should not be added to the list...
friend class const_iterator
Definition: qlist.h:264
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QEvent * event
Definition: qthread_p.h:78
QObject * receiver
Definition: qthread_p.h:77
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ cursorFlashTime()

static int QApplication::cursorFlashTime ( )
static

◆ desktop()

QDesktopWidget * QApplication::desktop ( )
static

Returns the desktop widget (also called the root window).

The desktop may be composed of multiple screens, so it would be incorrect, for example, to attempt to center some widget in the desktop's geometry. QDesktopWidget has various functions for obtaining useful geometries upon the desktop, such as QDesktopWidget::screenGeometry() and QDesktopWidget::availableGeometry().

On X11, it is also possible to draw on the desktop.

Definition at line 3320 of file qapplication.cpp.

Referenced by QPushButtonPrivate::adjustedMenuPosition(), QWidgetPrivate::adjustedSize(), QDialog::adjustPosition(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QBalloonTip::balloon(), QVistaHelper::basicWindowFrameColor(), QWidgetPrivate::create_sys(), QApplicationPrivate::dispatchEnterLeave(), QVistaHelper::drawTitleText(), effectiveState(), QDockWidget::event(), find_trans_colors(), findRealWindow(), flipYCoordinate(), fontMetrics(), QClipboardWatcher::getDataInFormat(), getScreen(), QTipLabel::getTipScreen(), QTabWidget::heightForWidth(), QColorDialogPrivate::init(), QFontDialogPrivate::init(), QWidgetResizeHandler::keyPressEvent(), QWidgetPrivate::mapFromGlobal(), QWidgetPrivate::mapToGlobal(), QMenuBar::minimumSizeHint(), QWidgetResizeHandler::mouseMoveEvent(), QSizeGrip::mousePressEvent(), parseGeometry(), QWSOnScreenSurface::permanentState(), QTipLabel::placeTip(), QMenu::popup(), QMenuBarPrivate::popupAction(), QMenuPrivate::popupGeometry(), QComboBoxPrivate::popupGeometry(), QToolButtonPrivate::popupTimerDone(), QDateTimeEditPrivate::positionCalendarPopup(), QBalloonTip::QBalloonTip(), qstring_to_xtp(), qt_check_clipboard_sentinel(), qt_check_selection_sentinel(), qt_cleanup(), qt_grab_cursor(), qt_qpa_set_cursor(), QWhatsThat::QWhatsThat(), QWidget::restoreGeometry(), QDockAreaLayoutInfo::restoreState(), QAlphaWidget::run(), QWidget::saveGeometry(), QWhatsThisPrivate::say(), QWidgetPrivate::setGeometry_sys(), QApplicationPrivate::setMaxWindowRect(), QWidgetPrivate::setMinimumSize_helper(), QSplashScreen::setPixmap(), QApplicationPrivate::setScreenTransformation(), QWizardHeader::setup(), QWidget::setWindowState(), QWhatsThat::showEvent(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), QToolTip::showText(), QWorkspace::sizeHint(), QProgressDialog::sizeHint(), QMdiArea::sizeHint(), QMenuBar::sizeHint(), QGraphicsView::sizeHint(), QTabWidget::sizeHint(), QWizard::sizeHint(), QWindowsXPStylePrivate::tabBody(), QPlatformScreen::topLevelAt(), QETWidget::translateConfigEvent(), QETWidget::translateTabletEvent(), QApplicationPrivate::translateTouchEvent(), QGLContext::updatePaintDevice(), QMessageBoxPrivate::updateSize(), and x11ProcessEvent().

3321 {
3322  if (!qt_desktopWidget || // not created yet
3323  !(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
3325  }
3326  return qt_desktopWidget;
3327 }
QDesktopWidget * qt_desktopWidget
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ desktopSettingsAware()

bool QApplication::desktopSettingsAware ( )
static

◆ doubleClickInterval()

static int QApplication::doubleClickInterval ( )
static

◆ event()

bool QApplication::event ( QEvent e)
protectedvirtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QCoreApplication.

Definition at line 2504 of file qapplication.cpp.

Referenced by compressEvent(), notify(), and ~QApplication().

2505 {
2506  Q_D(QApplication);
2507  if(e->type() == QEvent::Close) {
2508 #if defined(Q_OS_SYMBIAN)
2509  // In order to have proper application-exit effects on Symbian, certain
2510  // native APIs have to be called _before_ closing/destroying the widgets.
2511  bool effectStarted = qt_beginFullScreenEffect();
2512 #endif
2513  QCloseEvent *ce = static_cast<QCloseEvent*>(e);
2514  ce->accept();
2515  closeAllWindows();
2516 
2517  QWidgetList list = topLevelWidgets();
2518  for (int i = 0; i < list.size(); ++i) {
2519  QWidget *w = list.at(i);
2520  if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
2521  (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
2522  ce->ignore();
2523  break;
2524  }
2525  }
2526  if (ce->isAccepted()) {
2527  return true;
2528  } else {
2529 #if defined(Q_OS_SYMBIAN)
2530  if (effectStarted)
2531  qt_abortFullScreenEffect();
2532 #endif
2533  }
2534  } else if(e->type() == QEvent::LanguageChange) {
2535 #ifndef QT_NO_TRANSLATION
2537 #endif
2538 #if defined(QT_MAC_USE_COCOA)
2540 #endif
2541  QWidgetList list = topLevelWidgets();
2542  for (int i = 0; i < list.size(); ++i) {
2543  QWidget *w = list.at(i);
2544  if (!(w->windowType() == Qt::Desktop))
2546  }
2547 #ifndef Q_OS_WIN
2548  } else if (e->type() == QEvent::LocaleChange) {
2549  // on Windows the event propagation is taken care by the
2550  // WM_SETTINGCHANGE event handler.
2551  QWidgetList list = topLevelWidgets();
2552  for (int i = 0; i < list.size(); ++i) {
2553  QWidget *w = list.at(i);
2554  if (!(w->windowType() == Qt::Desktop)) {
2556  w->d_func()->setLocale_helper(QLocale(), true);
2557  }
2558  }
2559 #endif
2560  } else if (e->type() == QEvent::Timer) {
2561  QTimerEvent *te = static_cast<QTimerEvent*>(e);
2562  Q_ASSERT(te != 0);
2563  if (te->timerId() == d->toolTipWakeUp.timerId()) {
2564  d->toolTipWakeUp.stop();
2565  if (d->toolTipWidget) {
2566  QWidget *w = d->toolTipWidget->window();
2567  // show tooltip if WA_AlwaysShowToolTips is set, or if
2568  // any ancestor of d->toolTipWidget is the active
2569  // window
2571  while (w && !showToolTip) {
2572  showToolTip = w->isActiveWindow();
2573  w = w->parentWidget();
2574  w = w ? w->window() : 0;
2575  }
2576  if (showToolTip) {
2577  QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
2578  QApplication::sendEvent(d->toolTipWidget, &e);
2579  if (e.isAccepted())
2580  d->toolTipFallAsleep.start(2000, this);
2581  }
2582  }
2583  } else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
2584  d->toolTipFallAsleep.stop();
2585  }
2586  }
2587  return QCoreApplication::event(e);
2588 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
void qt_mac_post_retranslateAppMenu()
static bool qt_detectRTLLanguage()
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt, QStyle::ComplexControl complexControl, QStyle::SubControl subControl)
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
static void setLayoutDirection(Qt::LayoutDirection direction)
bool isAccepted() const
Definition: qcoreevent.h:307
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
static void closeAllWindows()
Closes all top-level windows.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586

◆ exec()

int QApplication::exec ( )
static

Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called via quit()).

It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.

Generally, no user interaction can take place before calling exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widgets call exec() to start a local event loop.

To make your application perform idle processing, i.e., executing a special function whenever there are no pending events, use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

We recommend that you connect clean-up code to the QCoreApplication::aboutToQuit() signal, instead of putting it in your application's main() function. This is because, on some platforms the QApplication::exec() call may not return. For example, on the Windows platform, when the user logs off, the system terminates the process after Qt closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the main() function, after the QApplication::exec() call.

See also
quitOnLastWindowClosed, quit(), exit(), processEvents(), QCoreApplication::exec()

Definition at line 3916 of file qapplication.cpp.

Referenced by main().

3917 {
3918 #ifndef QT_NO_ACCESSIBILITY
3920 #endif
3921  return QCoreApplication::exec();
3922 }
static int exec()
Enters the main event loop and waits until exit() is called.
#define qApp
static void setRootObject(QObject *)
Sets the root accessible object of this application to object.

◆ focusChanged

void QApplication::focusChanged ( QWidget old,
QWidget now 
)
signal
Since
4.1

This signal is emitted when the widget that has keyboard focus changed from old to now, i.e., because the user pressed the tab-key, clicked into a widget or changed the active window. Both old and now can be the null-pointer.

The signal is emitted after both widget have been notified about the change through QFocusEvent.

See also
QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason

◆ focusWidget()

QWidget * QApplication::focusWidget ( )
static

◆ font() [1/3]

QFont QApplication::font ( )
static

Returns the default application font.

See also
fontMetrics(), QWidget::font()

Definition at line 1982 of file qapplication.cpp.

Referenced by QPPDOptionsModel::data(), QVistaHelper::drawTitleBar(), QGraphicsWidget::event(), QWidget::event(), QFontDatabase::findFont(), QToolTip::font(), QTextItem::font(), QInputContext::font(), QFontDatabase::font(), font(), getFcPattern(), QGraphicsWidgetPrivate::initStyleOptionTitleBar(), loadFromDatabase(), loadWin(), QWidgetPrivate::naturalWidgetFont(), QGraphicsWidget::paintWindowFrame(), QMdiSubWindow::QMdiSubWindow(), QApplicationPrivate::qt_mac_apply_settings(), QWhatsThat::QWhatsThat(), QMdi::SimpleCascader::rearrange(), registerFont(), QWidgetBackingStore::removeDirtyWidget(), QFont::resolve(), QGraphicsScenePrivate::resolveFont(), setFont(), QGraphicsScene::setFont(), QApplicationPrivate::setSystemFont(), QWindowsVistaStyle::unpolish(), QMessageBoxPrivate::updateSize(), QGtkStyleUpdateScheduler::updateTheme(), and QApplicationPrivate::x11_apply_settings().

1983 {
1984  QMutexLocker locker(applicationFontMutex());
1986 #if defined(Q_OS_BLACKBERRY)
1987  // See http://docs.blackberry.com/en/developers/deliverables/41577/typography.jsp
1988  // which recommends using font family "Slate Pro" and normal font size of 8 points
1991 #else
1993 #endif
1994  }
1996 }
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QFont * app_font
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64

◆ font() [2/3]

QFont QApplication::font ( const QWidget widget)
static

Returns the default font for the widget.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
fontMetrics(), QWidget::setFont()

Definition at line 2009 of file qapplication.cpp.

2010 {
2011  FontHash *hash = app_fonts();
2012 
2013 #ifdef Q_WS_MAC
2014  // short circuit for small and mini controls
2015  if (widget->testAttribute(Qt::WA_MacSmallSize)) {
2016  return hash->value("QSmallFont");
2017  } else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
2018  return hash->value("QMiniFont");
2019  }
2020 #endif
2021  if (widget && hash && hash->size()) {
2023  hash->constFind(widget->metaObject()->className());
2024  if (it != hash->constEnd())
2025  return it.value();
2026  for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
2027  if (widget->inherits(it.key()))
2028  return it.value();
2029  }
2030  }
2031  return font();
2032 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QFont font()
Returns the default application font.
const Key & key() const
Returns the current item&#39;s key.
Definition: qhash.h:419
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ font() [3/3]

QFont QApplication::font ( const char *  className)
static

Returns the font for widgets of the given className.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setFont(), QWidget::font()

Definition at line 2044 of file qapplication.cpp.

2045 {
2046  FontHash *hash = app_fonts();
2047  if (className && hash && hash->size()) {
2049  if (it != hash->constEnd())
2050  return *it;
2051  }
2052  return font();
2053 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const char * className
Definition: qwizard.cpp:137
static QFont font()
Returns the default application font.
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295

◆ fontDatabaseChanged

void QApplication::fontDatabaseChanged ( )
signal

◆ fontMetrics()

QFontMetrics QApplication::fontMetrics ( )
static

Returns display (screen) font metrics for the application font.

See also
font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()

Definition at line 2345 of file qapplication.cpp.

Referenced by QDecorationWindows::region(), and QDecorationDefault::titleBarHeight().

2346 {
2347  return desktop()->fontMetrics();
2348 }
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).

◆ globalStrut()

static QSize QApplication::globalStrut ( )
static

◆ inputContext()

QInputContext * QApplication::inputContext ( ) const

Returns the QInputContext instance used by the application.

See also
setInputContext()

Definition at line 5719 of file qapplication.cpp.

Referenced by inputContext().

5720 {
5721  Q_D(const QApplication);
5722  Q_UNUSED(d);// only static members being used.
5724  return d->inputContext;
5725 #ifdef Q_WS_X11
5726  if (!X11)
5727  return 0;
5728  if (!d->inputContext) {
5729  QApplication *that = const_cast<QApplication *>(this);
5730  QInputContext *qic = QInputContextFactory::create(X11->default_im, that);
5731  // fallback to default X Input Method.
5732  if (!qic)
5733  qic = QInputContextFactory::create(QLatin1String("xim"), that);
5734  that->d_func()->inputContext = qic;
5735  }
5736 #elif defined(Q_OS_SYMBIAN)
5737  if (!d->inputContext) {
5738  QApplication *that = const_cast<QApplication *>(this);
5740  // Try hbim and coefep first, then try others.
5741  if (keys.contains(QLatin1String("hbim"))) {
5742  that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that);
5743  } else if (keys.contains(QLatin1String("coefep"))) {
5744  if (!that->d_func()->inputContextBeingCreated) {
5745  that->d_func()->inputContextBeingCreated = true;
5746  that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that);
5747  that->d_func()->inputContextBeingCreated = false;
5748  }
5749  } else {
5750  for (int c = 0; c < keys.size() && !d->inputContext; ++c) {
5751  that->d_func()->inputContext = QInputContextFactory::create(keys[c], that);
5752  }
5753  }
5754  }
5755 #endif
5756  return d->inputContext;
5757 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
static QInputContext * create(const QString &key, QObject *parent)
unsigned char c[8]
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QInputContext * inputContext() const
Returns the QInputContext instance used by the application.
#define X11
Definition: qt_x11_p.h:724
#define Q_D(Class)
Definition: qglobal.h:2482
QStringList keys
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static QStringList keys()
Returns the list of keys this factory can create input contexts for.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ isEffectEnabled()

bool QApplication::isEffectEnabled ( Qt::UIEffect  effect)
static

Returns true if effect is enabled; otherwise returns false.

By default, Qt will try to use the desktop settings. To prevent this, call setDesktopSettingsAware(false).

Note
All effects are disabled on screens running at less than 16-bit color depth.
See also
setEffectEnabled(), Qt::UIEffect

Definition at line 2875 of file qapplication_mac.mm.

Referenced by QMenu::popup(), QComboBox::showPopup(), QToolTip::showText(), QTipLabel::timerEvent(), QETWidget::translateCloseEvent(), and QETWidget::updateRegion().

2876 {
2878  return false;
2879 
2880  switch(effect) {
2881  case Qt::UI_AnimateMenu:
2883  case Qt::UI_FadeMenu:
2885  case Qt::UI_AnimateCombo:
2887  case Qt::UI_AnimateTooltip:
2889  case Qt::UI_FadeTooltip:
2891  case Qt::UI_AnimateToolBox:
2893  default:
2894  break;
2895  }
2897 }
static QColormap instance(int screen=-1)
static bool fade_tooltip
static bool animate_ui
static bool animate_combo
static bool animate_tooltip
static bool animate_toolbox
static bool animate_menu

◆ isLeftToRight()

bool QApplication::isLeftToRight ( )
inlinestatic

Returns true if the application's layout direction is Qt::LeftToRight; otherwise returns false.

See also
layoutDirection(), isRightToLeft()

Definition at line 234 of file qapplication.h.

234 { return layoutDirection() == Qt::LeftToRight; }
static Qt::LayoutDirection layoutDirection()

◆ isRightToLeft()

bool QApplication::isRightToLeft ( )
inlinestatic

◆ isSessionRestored()

bool QApplication::isSessionRestored ( ) const

Returns true if the application has been restored from an earlier Session Management{session}; otherwise returns false.

See also
sessionId(), commitData(), saveState()

Definition at line 3481 of file qapplication.cpp.

3482 {
3483  Q_D(const QApplication);
3484  return d->is_session_restored;
3485 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
#define Q_D(Class)
Definition: qglobal.h:2482

◆ keyboardInputDirection()

Qt::LayoutDirection QApplication::keyboardInputDirection ( )
static

Returns the current keyboard input direction.

Since
4.2

Definition at line 5808 of file qapplication.cpp.

Referenced by QDeclarativeTextPrivate::determineHorizontalAlignment(), QDeclarativeTextEditPrivate::determineHorizontalAlignment(), QDeclarativeTextInputPrivate::determineHorizontalAlignment(), QTextEngine::isRightToLeft(), and QLineControl::layoutDirection().

5809 {
5810  if (!QApplicationPrivate::checkInstance("keyboardInputDirection"))
5811  return Qt::LeftToRight;
5813 }
static bool checkInstance(const char *method)
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
Qt::LayoutDirection keyboardInputDirection
Definition: qkeymapper_p.h:156

◆ keyboardInputInterval()

static int QApplication::keyboardInputInterval ( )
static

◆ keyboardInputLocale()

QLocale QApplication::keyboardInputLocale ( )
static

Returns the current keyboard input locale.

Since
4.2

Definition at line 5793 of file qapplication.cpp.

5794 {
5795  if (!QApplicationPrivate::checkInstance("keyboardInputLocale"))
5796  return QLocale::c();
5798 }
static bool checkInstance(const char *method)
QLocale keyboardInputLocale
Definition: qkeymapper_p.h:155
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113

◆ keyboardModifiers()

Qt::KeyboardModifiers QApplication::keyboardModifiers ( )
static

Returns the current state of the modifier keys on the keyboard.

The current state is updated sychronously as the event queue is emptied of events that will spontaneously change the keyboard state (QEvent::KeyPress and QEvent::KeyRelease events).

It should be noted this may not reflect the actual keys held on the input device at the time of calling but rather the modifiers as last reported in one of the above events. If no keys are being held Qt::NoModifier is returned.

See also
mouseButtons(), queryKeyboardModifiers()

Definition at line 3390 of file qapplication.cpp.

Referenced by QFileDialogPrivate::_q_enterDirectory(), QDockWidget::event(), QToolBar::event(), QAbstractItemViewPrivate::extendedSelectionCommand(), findRealWindow(), handle_xdnd_position(), QX11Data::motifdndHandle(), QContextMenuEvent::QContextMenuEvent(), qt_cleanup(), qt_mac_dnd_update_action(), qt_mac_mouse_inside_answer_rect(), QCursor::setPos(), QMacStyle::styleHint(), QApplicationPrivate::translateRawTouchEvent(), QETWidget::translateTabletEvent(), and QX11Data::xdndHandleDrop().

3391 {
3393 }
static Qt::KeyboardModifiers modifier_buttons

◆ lastWindowClosed

void QApplication::lastWindowClosed ( )
signal

This signal is emitted from QApplication::exec() when the last visible primary window (i.

e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed.

By default,

  • this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus

  • QApplication implicitly quits when this signal is emitted.

This feature can be turned off by setting quitOnLastWindowClosed to false.

See also
QWidget::close()

◆ layoutDirection()

static Qt::LayoutDirection QApplication::layoutDirection ( )
static

◆ macEventFilter()

bool QApplication::macEventFilter ( EventHandlerCallRef  caller,
EventRef  event 
)
virtual
Warning
This virtual function is only used under Mac OS X, and behaves different depending on if Qt is based on Carbon or Cocoa.

For the Carbon port, If you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that Qt registers for from Mac OS X with this function being called with the caller and the event.

For the Cocoa port, If you create an application that inherits QApplication and reimplement this function, you get direct access to all Cocoa Events that Qt receives from Mac OS X with this function being called with the caller being 0 and the event being an NSEvent pointer:

NSEvent *e = reinterpret_cast<NSEvent *>(event);

Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.

Definition at line 2670 of file qapplication_mac.mm.

Referenced by QApplicationPrivate::globalEventProcessor().

2671 {
2672  return false;
2673 }

◆ mouseButtons()

Qt::MouseButtons QApplication::mouseButtons ( )
static

Returns the current state of the buttons on the mouse.

The current state is updated syncronously as the event queue is emptied of events that will spontaneously change the mouse state (QEvent::MouseButtonPress and QEvent::MouseButtonRelease events).

It should be noted this may not reflect the actual buttons held on the input device at the time of calling but rather the mouse buttons as last reported in one of the above events. If no mouse buttons are being held Qt::NoButton is returned.

See also
keyboardModifiers()

Definition at line 3431 of file qapplication.cpp.

Referenced by QDockWidget::event(), QToolBar::event(), flipPoint(), QApplicationPrivate::globalEventProcessor(), handle_xdnd_position(), QX11Data::motifdndHandle(), QContextMenuEvent::QContextMenuEvent(), qt_mac_mouse_inside_answer_rect(), QTabBarPrivate::refresh(), QCursor::setPos(), and QX11Data::xdndHandleDrop().

3432 {
3434 }
static Qt::MouseButtons mouse_buttons

◆ notify()

bool QApplication::notify ( QObject receiver,
QEvent e 
)
virtual

Reimplemented Function

Reimplemented from QCoreApplication.

Definition at line 3926 of file qapplication.cpp.

3927 {
3928  Q_D(QApplication);
3929  // no events are delivered after ~QCoreApplication() has started
3931  return true;
3932 
3933  if (receiver == 0) { // serious error
3934  qWarning("QApplication::notify: Unexpected null receiver");
3935  return true;
3936  }
3937 
3938 #ifndef QT_NO_DEBUG
3939  d->checkReceiverThread(receiver);
3940 #endif
3941 
3942  // capture the current mouse/keyboard state
3943  if(e->spontaneous()) {
3944  if (e->type() == QEvent::KeyPress
3945  || e->type() == QEvent::KeyRelease) {
3946  QKeyEvent *ke = static_cast<QKeyEvent*>(e);
3948  } else if(e->type() == QEvent::MouseButtonPress
3949  || e->type() == QEvent::MouseButtonRelease) {
3950  QMouseEvent *me = static_cast<QMouseEvent*>(e);
3952  if(me->type() == QEvent::MouseButtonPress)
3954  else
3956  }
3957 #if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT)
3958  else if (false
3959 # ifndef QT_NO_WHEELEVENT
3960  || e->type() == QEvent::Wheel
3961 # endif
3962 # ifndef QT_NO_TABLETEVENT
3963  || e->type() == QEvent::TabletMove
3964  || e->type() == QEvent::TabletPress
3965  || e->type() == QEvent::TabletRelease
3966 # endif
3967  ) {
3968  QInputEvent *ie = static_cast<QInputEvent*>(e);
3970  }
3971 #endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
3972  }
3973 
3974 #ifndef QT_NO_GESTURES
3975  // walk through parents and check for gestures
3976  if (d->gestureManager) {
3977  switch (e->type()) {
3978  case QEvent::Paint:
3979  case QEvent::MetaCall:
3984 #ifdef QT3_SUPPORT
3985  case QEvent::ChildInsertedRequest:
3986  case QEvent::ChildInserted:
3987  case QEvent::LayoutHint:
3988 #endif
3989  case QEvent::ChildRemoved:
3990  case QEvent::UpdateRequest:
3991  case QEvent::UpdateLater:
3993  case QEvent::LocaleChange:
3994  case QEvent::Style:
3995  case QEvent::IconDrag:
3996  case QEvent::StyleChange:
4005  break;
4006  default:
4007  if (d->gestureManager->thread() == QThread::currentThread()) {
4008  if (receiver->isWidgetType()) {
4009  if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
4010  return true;
4011  } else {
4012  // a special case for events that go to QGesture objects.
4013  // We pass the object to the gesture manager and it'll figure
4014  // out if it's QGesture or not.
4015  if (d->gestureManager->filterEvent(receiver, e))
4016  return true;
4017  }
4018  }
4019  break;
4020  }
4021  }
4022 #endif // QT_NO_GESTURES
4023 
4024  // User input and window activation makes tooltips sleep
4025  switch (e->type()) {
4026  case QEvent::Wheel:
4028  case QEvent::KeyPress:
4029  case QEvent::KeyRelease:
4030  case QEvent::FocusOut:
4031  case QEvent::FocusIn:
4035  d->toolTipFallAsleep.stop();
4036  // fall-through
4037  case QEvent::Leave:
4038  d->toolTipWakeUp.stop();
4039  default:
4040  break;
4041  }
4042 
4043  bool res = false;
4044  if (!receiver->isWidgetType()) {
4045  res = d->notify_helper(receiver, e);
4046  } else switch (e->type()) {
4047 #if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
4048  case QEvent::Accel:
4049  {
4050  if (d->use_compat()) {
4051  QKeyEvent* key = static_cast<QKeyEvent*>(e);
4052  res = d->notify_helper(receiver, e);
4053 
4054  if (!res && !key->isAccepted())
4055  res = d->qt_dispatchAccelEvent(static_cast<QWidget *>(receiver), key);
4056 
4057  // next lines are for compatibility with Qt <= 3.0.x: old
4058  // QAccel was listening on toplevel widgets
4059  if (!res && !key->isAccepted() && !static_cast<QWidget *>(receiver)->isWindow())
4060  res = d->notify_helper(static_cast<QWidget *>(receiver)->window(), e);
4061  }
4062  break;
4063  }
4064 #endif //QT3_SUPPORT && !QT_NO_SHORTCUT
4066  case QEvent::KeyPress:
4067  case QEvent::KeyRelease:
4068  {
4069  bool isWidget = receiver->isWidgetType();
4070  bool isGraphicsWidget = false;
4071 #ifndef QT_NO_GRAPHICSVIEW
4072  isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
4073 #endif
4074  if (!isWidget && !isGraphicsWidget) {
4075  res = d->notify_helper(receiver, e);
4076  break;
4077  }
4078 
4079  QKeyEvent* key = static_cast<QKeyEvent*>(e);
4080 #if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
4081  if (d->use_compat() && d->qt_tryComposeUnicode(static_cast<QWidget*>(receiver), key))
4082  break;
4083 #endif
4084  if (key->type()==QEvent::KeyPress) {
4085 #ifndef QT_NO_SHORTCUT
4086  // Try looking for a Shortcut before sending key events
4087  if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
4088  return res;
4089 #endif
4091  || key->key() == Qt::Key_Tab
4092  || key->key() == Qt::Key_Left
4093  || key->key() == Qt::Key_Up
4094  || key->key() == Qt::Key_Right
4095  || key->key() == Qt::Key_Down);
4096  }
4097  bool def = key->isAccepted();
4098  QPointer<QObject> pr = receiver;
4099  while (receiver) {
4100  if (def)
4101  key->accept();
4102  else
4103  key->ignore();
4104  res = d->notify_helper(receiver, e);
4105  QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
4106 #ifndef QT_NO_GRAPHICSVIEW
4107  QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
4108 #endif
4109 
4110  if ((res && key->isAccepted())
4111  /*
4112  QLineEdit will emit a signal on Key_Return, but
4113  ignore the event, and sometimes the connected
4114  slot deletes the QLineEdit (common in itemview
4115  delegates), so we have to check if the widget
4116  was destroyed even if the event was ignored (to
4117  prevent a crash)
4118 
4119  note that we don't have to reset pw while
4120  propagating (because the original receiver will
4121  be destroyed if one of its ancestors is)
4122  */
4123  || !pr
4124  || (isWidget && (w->isWindow() || !w->parentWidget()))
4125 #ifndef QT_NO_GRAPHICSVIEW
4126  || (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget()))
4127 #endif
4128  ) {
4129  break;
4130  }
4131 
4132 #ifndef QT_NO_GRAPHICSVIEW
4133  receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget();
4134 #else
4135  receiver = w->parentWidget();
4136 #endif
4137  }
4138  qt_in_tab_key_event = false;
4139  }
4140  break;
4144  case QEvent::MouseMove:
4145  {
4146  QWidget* w = static_cast<QWidget *>(receiver);
4147 
4148  QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
4149  QPoint relpos = mouse->pos();
4150 
4151  if (e->spontaneous()) {
4152 #ifndef QT_NO_IM
4153  QInputContext *ic = w->inputContext();
4154  if (ic
4156  && ic->filterEvent(mouse))
4157  return true;
4158 #endif
4159 
4160  if (e->type() == QEvent::MouseButtonPress) {
4164  }
4165 
4166  // ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms
4167  // like Mac OS X (probably others too), can optimize their views by not
4168  // dispatching mouse move events. We have attributes to control hover,
4169  // and mouse tracking, but as long as we are deciding to implement this
4170  // feature without choice of opting-in or out, you ALWAYS have to have
4171  // tracking enabled. Therefore, the other properties give a false sense of
4172  // performance enhancement.
4173  if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) {
4174  d->toolTipWidget = w;
4175  d->toolTipPos = relpos;
4176  d->toolTipGlobalPos = mouse->globalPos();
4177  d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this);
4178  }
4179  }
4180 
4181  bool eventAccepted = mouse->isAccepted();
4182 
4183  QPointer<QWidget> pw = w;
4184  while (w) {
4185  QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(),
4186  mouse->modifiers());
4187  me.spont = mouse->spontaneous();
4188  // throw away any mouse-tracking-only mouse events
4189  if (!w->hasMouseTracking()
4190  && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
4191  // but still send them through all application event filters (normally done by notify_helper)
4192  for (int i = 0; i < d->eventFilters.size(); ++i) {
4193  register QObject *obj = d->eventFilters.at(i);
4194  if (!obj)
4195  continue;
4196  if (obj->d_func()->threadData != w->d_func()->threadData) {
4197  qWarning("QApplication: Object event filter cannot be in a different thread.");
4198  continue;
4199  }
4200  if (obj->eventFilter(w, w == receiver ? mouse : &me))
4201  break;
4202  }
4203  res = true;
4204  } else {
4206  res = d->notify_helper(w, w == receiver ? mouse : &me);
4207  e->spont = false;
4208  }
4209  eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
4210  if (res && eventAccepted)
4211  break;
4213  break;
4214  relpos += w->pos();
4215  w = w->parentWidget();
4216  }
4217 
4218  mouse->setAccepted(eventAccepted);
4219 
4220  if (e->type() == QEvent::MouseMove) {
4221  if (!pw)
4222  break;
4223 
4224  w = static_cast<QWidget *>(receiver);
4225  relpos = mouse->pos();
4226  QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
4227  while (w) {
4228  if (w->testAttribute(Qt::WA_Hover) &&
4230  QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff);
4231  d->notify_helper(w, &he);
4232  }
4234  break;
4235  relpos += w->pos();
4236  w = w->parentWidget();
4237  }
4238  }
4239 
4240  d->hoverGlobalPos = mouse->globalPos();
4241  }
4242  break;
4243 #ifndef QT_NO_WHEELEVENT
4244  case QEvent::Wheel:
4245  {
4246  QWidget* w = static_cast<QWidget *>(receiver);
4247  QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
4248  QPoint relpos = wheel->pos();
4249  bool eventAccepted = wheel->isAccepted();
4250 
4251  if (e->spontaneous()) {
4255  }
4256 
4257  while (w) {
4258  QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(),
4259  wheel->modifiers(), wheel->orientation());
4260  we.spont = wheel->spontaneous();
4261  res = d->notify_helper(w, w == receiver ? wheel : &we);
4262  eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted();
4263  e->spont = false;
4264  if ((res && eventAccepted)
4266  break;
4267 
4268  relpos += w->pos();
4269  w = w->parentWidget();
4270  }
4271  wheel->setAccepted(eventAccepted);
4272  }
4273  break;
4274 #endif
4275 #ifndef QT_NO_CONTEXTMENU
4276  case QEvent::ContextMenu:
4277  {
4278  QWidget* w = static_cast<QWidget *>(receiver);
4279  QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
4280  QPoint relpos = context->pos();
4281  bool eventAccepted = context->isAccepted();
4282  while (w) {
4283  QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
4284  ce.spont = e->spontaneous();
4285  res = d->notify_helper(w, w == receiver ? context : &ce);
4286  eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
4287  e->spont = false;
4288 
4289  if ((res && eventAccepted)
4291  break;
4292 
4293  relpos += w->pos();
4294  w = w->parentWidget();
4295  }
4296  context->setAccepted(eventAccepted);
4297  }
4298  break;
4299 #endif // QT_NO_CONTEXTMENU
4300 #ifndef QT_NO_TABLETEVENT
4301  case QEvent::TabletMove:
4302  case QEvent::TabletPress:
4303  case QEvent::TabletRelease:
4304  {
4305  QWidget *w = static_cast<QWidget *>(receiver);
4306  QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
4307  QPoint relpos = tablet->pos();
4308  bool eventAccepted = tablet->isAccepted();
4309  while (w) {
4310  QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
4311  tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
4312  tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
4313  tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
4314  tablet->modifiers(), tablet->uniqueId());
4315  te.spont = e->spontaneous();
4316  res = d->notify_helper(w, w == receiver ? tablet : &te);
4317  eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
4318  e->spont = false;
4319  if ((res && eventAccepted)
4320  || w->isWindow()
4322  break;
4323 
4324  relpos += w->pos();
4325  w = w->parentWidget();
4326  }
4327  tablet->setAccepted(eventAccepted);
4328  qt_tabletChokeMouse = tablet->isAccepted();
4329  }
4330  break;
4331 #endif // QT_NO_TABLETEVENT
4332 
4333 #if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS)
4334  case QEvent::ToolTip:
4335  case QEvent::WhatsThis:
4337  {
4338  QWidget* w = static_cast<QWidget *>(receiver);
4339  QHelpEvent *help = static_cast<QHelpEvent*>(e);
4340  QPoint relpos = help->pos();
4341  bool eventAccepted = help->isAccepted();
4342  while (w) {
4343  QHelpEvent he(help->type(), relpos, help->globalPos());
4344  he.spont = e->spontaneous();
4345  res = d->notify_helper(w, w == receiver ? help : &he);
4346  e->spont = false;
4347  eventAccepted = (w == receiver ? help : &he)->isAccepted();
4348  if ((res && eventAccepted) || w->isWindow())
4349  break;
4350 
4351  relpos += w->pos();
4352  w = w->parentWidget();
4353  }
4354  help->setAccepted(eventAccepted);
4355  }
4356  break;
4357 #endif
4358 #if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS)
4359  case QEvent::StatusTip:
4361  {
4362  QWidget *w = static_cast<QWidget *>(receiver);
4363  while (w) {
4364  res = d->notify_helper(w, e);
4365  if ((res && e->isAccepted()) || w->isWindow())
4366  break;
4367  w = w->parentWidget();
4368  }
4369  }
4370  break;
4371 #endif
4372 
4373 #ifndef QT_NO_DRAGANDDROP
4374  case QEvent::DragEnter: {
4375  QWidget* w = static_cast<QWidget *>(receiver);
4376  QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
4377 #ifdef Q_WS_MAC
4378  // HIView has a slight difference in how it delivers events to children and parents
4379  // It will not give a leave to a child's parent when it enters a child.
4380  QWidget *currentTarget = QDragManager::self()->currentTarget();
4381  if (currentTarget) {
4382  // Assume currentTarget did not get a leave
4384  QApplication::sendEvent(currentTarget, &event);
4385  }
4386 #endif
4387 #ifndef QT_NO_GRAPHICSVIEW
4388  // QGraphicsProxyWidget handles its own propagation,
4389  // and we must not change QDragManagers currentTarget.
4390  QWExtra *extra = w->window()->d_func()->extra;
4391  if (extra && extra->proxyWidget) {
4392  res = d->notify_helper(w, dragEvent);
4393  break;
4394  }
4395 #endif
4396  while (w) {
4397  if (w->isEnabled() && w->acceptDrops()) {
4398  res = d->notify_helper(w, dragEvent);
4399  if (res && dragEvent->isAccepted()) {
4401  break;
4402  }
4403  }
4404  if (w->isWindow())
4405  break;
4406  dragEvent->p = w->mapToParent(dragEvent->p);
4407  w = w->parentWidget();
4408  }
4409  }
4410  break;
4411  case QEvent::DragMove:
4412  case QEvent::Drop:
4413  case QEvent::DragLeave: {
4414  QWidget* w = static_cast<QWidget *>(receiver);
4415 #ifndef QT_NO_GRAPHICSVIEW
4416  // QGraphicsProxyWidget handles its own propagation,
4417  // and we must not change QDragManagers currentTarget.
4418  QWExtra *extra = w->window()->d_func()->extra;
4419  bool isProxyWidget = extra && extra->proxyWidget;
4420  if (!isProxyWidget)
4421 #endif
4423 
4424  if (!w) {
4425 #ifdef Q_WS_MAC
4426  // HIView has a slight difference in how it delivers events to children and parents
4427  // It will not give an enter to a child's parent when it leaves the child.
4428  if (e->type() == QEvent::DragLeave)
4429  break;
4430  // Assume that w did not get an enter.
4431  QDropEvent *dropEvent = static_cast<QDropEvent *>(e);
4432  QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(),
4433  dropEvent->mimeData(), dropEvent->mouseButtons(),
4434  dropEvent->keyboardModifiers());
4435  QApplication::sendEvent(receiver, &dragEnterEvent);
4437  if (!w)
4438 #endif
4439  break;
4440  }
4441  if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
4442  QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
4443  QWidget *origReciver = static_cast<QWidget *>(receiver);
4444  while (origReciver && w != origReciver) {
4445  dragEvent->p = origReciver->mapToParent(dragEvent->p);
4446  origReciver = origReciver->parentWidget();
4447  }
4448  }
4449  res = d->notify_helper(w, e);
4450  if (e->type() != QEvent::DragMove
4451 #ifndef QT_NO_GRAPHICSVIEW
4452  && !isProxyWidget
4453 #endif
4454  )
4456  }
4457  break;
4458 #endif
4459  case QEvent::TouchBegin:
4460  // Note: TouchUpdate and TouchEnd events are never propagated
4461  {
4462  QWidget *widget = static_cast<QWidget *>(receiver);
4463  QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
4464  bool eventAccepted = touchEvent->isAccepted();
4465  if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) {
4466  // give the widget focus if the focus policy allows it
4470  }
4471 
4472  while (widget) {
4473  // first, try to deliver the touch event
4474  bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
4475  touchEvent->setWidget(widget);
4476  touchEvent->setAccepted(acceptTouchEvents);
4478  res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
4479  eventAccepted = touchEvent->isAccepted();
4480  if (p.isNull()) {
4481  // widget was deleted
4482  widget = 0;
4483  } else {
4484  widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
4485  }
4486  touchEvent->spont = false;
4487  if (res && eventAccepted) {
4488  // the first widget to accept the TouchBegin gets an implicit grab.
4489  for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
4490  const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
4491  d->widgetForTouchPointId[touchPoint.id()] = widget;
4492  }
4493  break;
4494  } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
4495  break;
4496  }
4497  QPoint offset = widget->pos();
4498  widget = widget->parentWidget();
4499  touchEvent->setWidget(widget);
4500  for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
4501  QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
4502  QRectF rect = pt.rect();
4503  rect.moveCenter(offset);
4504  pt.d->rect = rect;
4505  pt.d->startPos = pt.startPos() + offset;
4506  pt.d->lastPos = pt.lastPos() + offset;
4507  }
4508  }
4509 
4510  touchEvent->setAccepted(eventAccepted);
4511  break;
4512  }
4515 #ifndef QT_NO_IM
4516  if (receiver->isWidgetType()) {
4517  QWidget *w = static_cast<QWidget *>(receiver);
4518  QInputContext *ic = w->inputContext();
4519  if (ic && ic->filterEvent(e)) {
4520  break;
4521  }
4522  }
4523 #endif
4524  res = d->notify_helper(receiver, e);
4525  break;
4526 
4527 #ifndef QT_NO_GESTURES
4528  case QEvent::NativeGesture:
4529  {
4530  // only propagate the first gesture event (after the GID_BEGIN)
4531  QWidget *w = static_cast<QWidget *>(receiver);
4532  while (w) {
4533  e->ignore();
4534  res = d->notify_helper(w, e);
4535  if ((res && e->isAccepted()) || w->isWindow())
4536  break;
4537  w = w->parentWidget();
4538  }
4539  break;
4540  }
4541  case QEvent::Gesture:
4543  {
4544  if (receiver->isWidgetType()) {
4545  QWidget *w = static_cast<QWidget *>(receiver);
4546  QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
4547  QList<QGesture *> allGestures = gestureEvent->gestures();
4548 
4549  bool eventAccepted = gestureEvent->isAccepted();
4550  bool wasAccepted = eventAccepted;
4551  while (w) {
4552  // send only gestures the widget expects
4553  QList<QGesture *> gestures;
4554  QWidgetPrivate *wd = w->d_func();
4555  for (int i = 0; i < allGestures.size();) {
4556  QGesture *g = allGestures.at(i);
4559  wd->gestureContext.find(type);
4560  bool deliver = contextit != wd->gestureContext.end() &&
4561  (g->state() == Qt::GestureStarted || w == receiver ||
4562  (contextit.value() & Qt::ReceivePartialGestures));
4563  if (deliver) {
4564  allGestures.removeAt(i);
4565  gestures.append(g);
4566  } else {
4567  ++i;
4568  }
4569  }
4570  if (!gestures.isEmpty()) { // we have gestures for this w
4571  QGestureEvent ge(gestures);
4572  ge.t = gestureEvent->t;
4573  ge.spont = gestureEvent->spont;
4574  ge.m_accept = wasAccepted;
4575  ge.d_func()->accepted = gestureEvent->d_func()->accepted;
4576  res = d->notify_helper(w, &ge);
4577  gestureEvent->spont = false;
4578  eventAccepted = ge.isAccepted();
4579  for (int i = 0; i < gestures.size(); ++i) {
4580  QGesture *g = gestures.at(i);
4581  // Ignore res [event return value] because handling of multiple gestures
4582  // packed into a single QEvent depends on not consuming the event
4583  if (eventAccepted || ge.isAccepted(g)) {
4584  // if the gesture was accepted, mark the target widget for it
4585  gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
4586  gestureEvent->setAccepted(g, true);
4587  } else {
4588  // if the gesture was explicitly ignored by the application,
4589  // put it back so a parent can get it
4590  allGestures.append(g);
4591  }
4592  }
4593  }
4594  if (allGestures.isEmpty()) // everything delivered
4595  break;
4596  if (w->isWindow())
4597  break;
4598  w = w->parentWidget();
4599  }
4600  foreach (QGesture *g, allGestures)
4601  gestureEvent->setAccepted(g, false);
4602  gestureEvent->m_accept = false; // to make sure we check individual gestures
4603  } else {
4604  res = d->notify_helper(receiver, e);
4605  }
4606  break;
4607  }
4608 #endif // QT_NO_GESTURES
4609 #ifdef QT_MAC_USE_COCOA
4610  case QEvent::Enter:
4611  if (receiver->isWidgetType()) {
4612  QWidget *w = static_cast<QWidget *>(receiver);
4614  qt_widget_private(w)->registerTouchWindow(true);
4615  }
4616  res = d->notify_helper(receiver, e);
4617  break;
4618  case QEvent::Leave:
4619  if (receiver->isWidgetType()) {
4620  QWidget *w = static_cast<QWidget *>(receiver);
4622  qt_widget_private(w)->registerTouchWindow(false);
4623  }
4624  res = d->notify_helper(receiver, e);
4625  break;
4626 #endif
4627  default:
4628  res = d->notify_helper(receiver, e);
4629  break;
4630  }
4631 
4632  return res;
4633 }
double d
Definition: qnumeric_p.h:62
void setAccepted(QGesture *, bool)
Sets the accept flag of the given gesture object to the specified value.
Definition: qevent.cpp:4929
int id() const
Returns the id number of this touch point.
Definition: qevent.cpp:4445
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QPointer< QWidget > widget
ushort t
Definition: qcoreevent.h:316
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
Qt::DropActions possibleActions() const
Returns an OR-combination of possible drop actions.
Definition: qevent.h:490
int xTilt() const
Returns the angle between the device (a pen, for example) and the perpendicular in the direction of t...
Definition: qevent.h:207
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
QRectF rect() const
Returns the rect for this touch point, relative to the widget or QGraphicsItem that received the even...
Definition: qevent.cpp:4624
The QHoverEvent class contains parameters that describe a mouse event.
Definition: qevent.h:125
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
ushort spont
Definition: qcoreevent.h:320
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QPointF & hiResGlobalPos() const
The high precision coordinates delivered from the tablet expressed.
Definition: qevent.h:193
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
T * qobject_cast(QObject *object)
Definition: qobject.h:375
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const QPoint & pos() const
Returns the position of the device, relative to the widget that received the event.
Definition: qevent.h:191
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::KeyboardModifiers keyboardModifiers() const
Returns the modifier keys that are pressed.
Definition: qevent.h:488
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
PointerType pointerType() const
Returns the type of point that generated the event.
Definition: qevent.h:201
QGraphicsProxyWidget * proxyWidget
Definition: qwidget_p.h:251
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
Definition: qwidget_p.h:763
static void giveFocusAccordingToFocusPolicy(QWidget *w, Qt::FocusPolicy focusPolicy, Qt::FocusReason focusReason)
QList< QTouchEvent::TouchPoint > _touchPoints
Definition: qevent.h:832
The QGestureEvent class provides the description of triggered gestures.
Definition: qevent.h:841
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isAccepted() const
Definition: qcoreevent.h:307
qint64 uniqueId() const
Returns a unique ID for the current device, making it possible to differentiate between multiple devi...
Definition: qevent.h:202
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QPointF lastPos() const
Returns the position of this touch point from the previous touch event, relative to the widget or QGr...
Definition: qevent.cpp:4571
#define qApp
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition: qcoreevent.h:304
Q_CORE_EXPORT void qWarning(const char *,...)
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
Qt::MouseButtons buttons() const
Returns the mouse state when the event occurred.
Definition: qevent.h:158
QMap< Qt::GestureType, QWidget * > targetWidgets
Definition: qevent_p.h:170
static Bigint * diff(Bigint *a, Bigint *b)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QList< QGesture * > gestures() const
Returns all gestures that are delivered in the event.
Definition: qevent.cpp:4873
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
Qt::Orientation orientation() const
Returns the wheel&#39;s orientation.
Definition: qevent.h:159
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
GestureType
Definition: qnamespace.h:1759
bool acceptDrops
whether drop events are enabled for this widget
Definition: qwidget.h:197
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
bool isEnabled() const
Definition: qwidget.h:948
The QTabletEvent class contains parameters that describe a Tablet event.
Definition: qevent.h:179
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
Reason reason() const
Returns the reason for this context event.
Definition: qevent.h:415
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
static QDragManager * self()
Definition: qdnd.cpp:163
const QPoint & pos() const
Returns the position of the mouse cursor relative to the widget that received the event...
Definition: qevent.h:151
#define QT_NO_WHEELEVENT
qreal pressure() const
Returns the pressure for the device.
Definition: qevent.h:203
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
Qt::MouseButtons mouseButtons() const
Returns the mouse buttons that are pressed.
Definition: qevent.h:487
void setCurrentTarget(QWidget *target, bool dropped=false)
Definition: qdnd.cpp:260
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
static QWidget * activePopupWidget()
Returns the active popup widget.
int z() const
Returns the z position of the device.
Definition: qevent.h:204
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
static Qt::KeyboardModifiers modifier_buttons
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
bool hasMouseTracking() const
Definition: qwidget.h:993
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
QWidget * currentTarget()
Definition: qdnd.cpp:273
QGestureEventPrivate * d_func()
Definition: qevent.cpp:5079
const QPoint & globalPos() const
Returns the global position of the device at the time of the event.
Definition: qevent.h:192
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
Definition: qevent.h:555
bool qt_tabletChokeMouse
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPoint mapToParent(const QPoint &) const
Translates the widget coordinate pos to a coordinate in the parent widget.
Definition: qwidget.cpp:4459
const QList< QTouchEvent::TouchPoint > & touchPoints() const
Returns the list of touch points contained in the touch event.
Definition: qevent.h:820
int yTilt() const
Returns the angle between the device (a pen, for example) and the perpendicular in the direction of t...
Definition: qevent.h:208
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
qreal tangentialPressure() const
Returns the tangential pressure for the device.
Definition: qevent.h:205
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
Definition: qevent.h:598
QTouchEventTouchPointPrivate * d
Definition: qevent.h:800
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:152
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
bool isAccepted(QGesture *) const
Returns true if the gesture is accepted; otherwise returns false.
Definition: qevent.cpp:4968
The QInputEvent class is the base class for events that describe user input.
Definition: qevent.h:74
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
Qt::GestureState state
the current state of the gesture
Definition: qgesture.h:69
The QTouchEvent class contains parameters that describe a touch event.
Definition: qevent.h:741
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
void setWidget(QWidget *awidget)
Definition: qevent.h:823
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
qreal rotation() const
Returns the rotation of the current device in degress.
Definition: qevent.h:206
QTouchEventSequence touchEvent(QWidget *widget=0, QTouchEvent::DeviceType deviceType=QTouchEvent::TouchScreen)
Creates and returns a QTouchEventSequence for the device deviceType to simulate events for widget...
Definition: qtesttouch.h:141
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
QPoint p
Definition: qevent.h:519
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
bool qt_in_tab_key_event
void moveCenter(const QPointF &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.h:705
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QMap< Qt::GestureType, bool > accepted
Definition: qevent_p.h:169
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
TabletDevice device() const
Returns the type of device that generated the event.
Definition: qevent.h:200
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
static Qt::MouseButtons mouse_buttons
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented in a subclass to filter input events.
QPointF startPos() const
Returns the starting position of this touch point, relative to the widget or QGraphicsItem that recei...
Definition: qevent.cpp:4522
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition: qevent.h:597

◆ overrideCursor()

QCursor * QApplication::overrideCursor ( )
static

Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the language used.

Returns the active application override cursor.

This function returns 0 if no application cursor has been defined (i.e. the internal cursor stack is empty).

See also
setOverrideCursor(), restoreOverrideCursor()

Definition at line 3855 of file qapplication.cpp.

Referenced by effectiveState(), qt_mac_updateCursorWithWidgetUnderMouse(), qt_qpa_set_cursor(), qt_try_modal(), qt_win_set_cursor(), qt_x11_enforce_cursor(), QtWndProc(), and QETWidget::translateMouseEvent().

3856 {
3857  return qApp->d_func()->cursor_list.isEmpty() ? 0 : &qApp->d_func()->cursor_list.first();
3858 }
#define qApp

◆ palette() [1/3]

QPalette QApplication::palette ( )
static

◆ palette() [2/3]

QPalette QApplication::palette ( const QWidget widget)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.If a widget is passed, the default palette for the widget's class is returned.

This may or may not be the application palette. In most cases there is no special palette for certain types of widgets, but one notable exception is the popup menu under Windows, if the user has defined a special background color for menus in the display settings.

See also
setPalette(), QWidget::palette()

Definition at line 1826 of file qapplication.cpp.

1827 {
1828  PaletteHash *hash = app_palettes();
1829  if (w && hash && hash->size()) {
1830  QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
1831  if (it != hash->constEnd())
1832  return *it;
1833  for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
1834  if (w->inherits(it.key()))
1835  return it.value();
1836  }
1837  }
1838  return palette();
1839 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
static QPalette palette()
Returns the application palette.
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const Key & key() const
Returns the current item&#39;s key.
Definition: qhash.h:419
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295

◆ palette() [3/3]

QPalette QApplication::palette ( const char *  className)
static

Returns the palette for widgets of the given className.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setPalette(), QWidget::palette()

Definition at line 1851 of file qapplication.cpp.

1852 {
1854  palette();
1855  PaletteHash *hash = app_palettes();
1856  if (className && hash && hash->size()) {
1858  if (it != hash->constEnd())
1859  return *it;
1860  }
1862 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
static QPalette palette()
Returns the application palette.
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
static QPalette * app_pal
const char * className
Definition: qwizard.cpp:137
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295

◆ queryKeyboardModifiers()

Qt::KeyboardModifiers QApplication::queryKeyboardModifiers ( )
static

Queries and returns the state of the modifier keys on the keyboard.

Unlike keyboardModifiers, this method returns the actual keys held on the input device at the time of calling the method.

It does not rely on the keypress events having been received by this process, which makes it possible to check the modifiers while moving a window, for instance. Note that in most cases, you should use keyboardModifiers(), which is faster and more accurate since it contains the state of the modifiers as they were when the currently processed event was received.

See also
keyboardModifiers()
Since
4.8

Definition at line 1436 of file qapplication_mac.mm.

Referenced by parseGeometry(), qt_win_getKeyboardModifiers(), syncX(), and QX11Data::xdndHandleDrop().

1437 {
1438  return qt_mac_get_modifiers(GetCurrentEventKeyModifiers());
1439 }
Qt::KeyboardModifiers qt_mac_get_modifiers(int keys)

◆ quitOnLastWindowClosed()

static bool QApplication::quitOnLastWindowClosed ( )
static

◆ qwsEventFilter()

bool QApplication::qwsEventFilter ( QWSEvent event)
virtual

This virtual function is only implemented under Qt for Embedded Linux.

If you create an application that inherits QApplication and reimplement this function, you get direct access to all QWS (Q Window System) events that the are received from the QWS master process. The events are passed in the event parameter.

Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.

Definition at line 3090 of file qapplication_qws.cpp.

3091 {
3092  return false;
3093 }

◆ qwsProcessEvent()

int QApplication::qwsProcessEvent ( QWSEvent event)
Warning
This function is not part of the public interface.

Definition at line 2712 of file qapplication_qws.cpp.

2713 {
2714  Q_D(QApplication);
2715  QScopedLoopLevelCounter loopLevelCounter(d->threadData);
2716  int oldstate = -1;
2717  bool isMove = false;
2718  if (event->type == QWSEvent::Mouse) {
2719  QWSMouseEvent::SimpleData &mouse = event->asMouse()->simpleData;
2720  isMove = mouse_x_root != mouse.x_root || mouse_y_root != mouse.y_root;
2721  oldstate = mouse_state;
2722  mouse_x_root = mouse.x_root;
2723  mouse_y_root = mouse.y_root;
2724  mouse_state = mouse.state;
2725  }
2726 
2727  long unused;
2728  if (filterEvent(event, &unused)) // send through app filter
2729  return 1;
2730 
2731  if (qwsEventFilter(event)) // send through app filter
2732  return 1;
2733 
2734 
2735 #ifndef QT_NO_QWS_PROPERTIES
2736  if (event->type == QWSEvent::PropertyNotify) {
2738  if (e->simpleData.property == 424242) { // Clipboard
2739 #ifndef QT_NO_CLIPBOARD
2740  if (qt_clipboard) {
2741  QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
2743  }
2744 #endif
2745  }
2746  }
2747 #endif //QT_NO_QWS_PROPERTIES
2748 #ifndef QT_NO_COP
2749  else if (event->type == QWSEvent::QCopMessage) {
2750  QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(event);
2752  return 0;
2753  }
2754 #endif
2755 #if !defined(QT_NO_QWS_QPF2)
2756  else if (event->type == QWSEvent::Font) {
2757  QWSFontEvent *e = static_cast<QWSFontEvent *>(event);
2760  }
2761  }
2762 #endif
2763 
2764  QPointer<QETWidget> widget = static_cast<QETWidget*>(QWidget::find(WId(event->window())));
2765 #ifdef Q_BACKINGSTORE_SUBSURFACES
2766  if (!widget) { // XXX: hw: hack for accessing subsurfaces
2767  extern QWSWindowSurface* qt_findWindowSurface(int);
2768  QWSWindowSurface *s = qt_findWindowSurface(event->window());
2769  if (s)
2770  widget = static_cast<QETWidget*>(s->window());
2771  }
2772 #endif
2773 
2774 #ifndef QT_NO_DIRECTPAINTER
2775  if (!widget && d->directPainters) {
2776  QDirectPainter *dp = d->directPainters->value(WId(event->window()));
2777  if (dp == 0) {
2778  } else if (event->type == QWSEvent::Region) {
2779  QWSRegionEvent *e = static_cast<QWSRegionEvent*>(event);
2780  QRegion reg;
2783  return 1;
2784 #ifndef QT_NO_QWSEMBEDWIDGET
2785  } else if (event->type == QWSEvent::Embed) {
2786  QWSEmbedEvent *e = static_cast<QWSEmbedEvent*>(event);
2788  return 1;
2789  #endif // QT_NO_QWSEMBEDWIDGET
2790  }
2791  }
2792 #endif // QT_NO_DIRECTPAINTER
2793 
2794 #ifndef QT_NO_QWS_MANAGER
2795  if (d->last_manager && event->type == QWSEvent::Mouse) {
2796  QPoint pos(event->asMouse()->simpleData.x_root, event->asMouse()->simpleData.y_root);
2797  if (!d->last_manager->cachedRegion().contains(pos)) {
2798  // MouseEvent not yet delivered, so QCursor::pos() is not yet updated, sending 2 x pos
2799  QMouseEvent outside(QEvent::MouseMove, pos, pos, Qt::NoButton, 0, 0);
2800  QApplication::sendSpontaneousEvent(d->last_manager, &outside);
2801  d->last_manager = 0;
2802  qt_last_cursor = 0xffffffff; //decoration is like another window; must redo cursor
2803  }
2804  }
2805 #endif // QT_NO_QWS_MANAGER
2806 
2807  QETWidget *keywidget=0;
2808  bool grabbed=false;
2809  if (event->type==QWSEvent::Key || event->type == QWSEvent::IMEvent || event->type == QWSEvent::IMQuery) {
2810  keywidget = static_cast<QETWidget*>(QWidget::keyboardGrabber());
2811  if (keywidget) {
2812  grabbed = true;
2813  } else {
2814  if (QWidget *popup = QApplication::activePopupWidget()) {
2815  if (popup->focusWidget())
2816  keywidget = static_cast<QETWidget*>(popup->focusWidget());
2817  else
2818  keywidget = static_cast<QETWidget*>(popup);
2820  keywidget = static_cast<QETWidget*>(QApplicationPrivate::focus_widget);
2821  else if (widget)
2822  keywidget = static_cast<QETWidget*>(widget->window());
2823  }
2824  } else if (event->type==QWSEvent::MaxWindowRect) {
2825  QRect r = static_cast<QWSMaxWindowRectEvent*>(event)->simpleData.rect;
2826  setMaxWindowRect(r);
2827  return 0;
2828 #ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
2829  } else if (event->type == QWSEvent::ScreenTransformation) {
2833  return 0;
2834 #endif
2835  } else if (widget && event->type==QWSEvent::Mouse) {
2836  // The mouse event is to one of my top-level widgets
2837  // which one?
2838  const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton;
2839  QPoint p(event->asMouse()->simpleData.x_root,
2840  event->asMouse()->simpleData.y_root);
2841  int mouseButtonState = event->asMouse()->simpleData.state & btnMask;
2842  static int btnstate = 0;
2843 
2844  QETWidget *w = static_cast<QETWidget*>(QWidget::mouseGrabber());
2845  if (w && !mouseButtonState && qt_pressGrab == w)
2846  qt_pressGrab = 0;
2847 #ifndef QT_NO_QWS_MANAGER
2848  if (!w)
2849  w = static_cast<QETWidget*>(QWSManager::grabbedMouse());
2850 #endif
2851  if (w) {
2852  // Our mouse is grabbed - send it.
2853  widget = w;
2854  btnstate = mouseButtonState;
2855  } else {
2856  static QWidget *gw = 0;
2857  // Three jobs to do here:
2858  // 1. find the child widget this event belongs to.
2859  // 2. make sure the cursor is correct.
2860  // 3. handle implicit mouse grab due to button press.
2861  w = widget; // w is the widget the cursor is in.
2862 
2863  //### ??? alloc_region
2864  //#### why should we get events outside alloc_region ????
2865  if (1 /*widget->data->alloc_region.contains(dp) */) {
2866  // Find the child widget that the cursor is in.
2867  w = static_cast<QETWidget*>(widget->childAt(widget->mapFromParent(p)));
2868  if (!w)
2869  w = widget;
2870 #ifndef QT_NO_CURSOR
2871  // Update Cursor.
2872  if (!gw || gw != w || qt_last_cursor == 0xffffffff) {
2873  QCursor *curs = 0;
2874  if (!qApp->d_func()->cursor_list.isEmpty())
2875  curs = &qApp->d_func()->cursor_list.first();
2876  else if (w->d_func()->extraData())
2877  curs = w->d_func()->extraData()->curs;
2878  QWidget *pw = w;
2879  // If this widget has no cursor set, try parent.
2880  while (!curs) {
2881  pw = pw->parentWidget();
2882  if (!pw)
2883  break;
2884  if (pw->d_func()->extraData())
2885  curs = pw->d_func()->extraData()->curs;
2886  }
2887  if (!qws_overrideCursor) {
2888  if (curs)
2889  QPaintDevice::qwsDisplay()->selectCursor(widget, curs->handle());
2890  else
2892  }
2893  }
2894 #endif
2895  gw = w;
2896  } else {
2897  // This event is not for any of our widgets
2898  gw = 0;
2899  }
2900  if (mouseButtonState && !btnstate) {
2901  // The server has grabbed the mouse for us.
2902  // Remember which of my widgets has it.
2903  qt_pressGrab = w;
2904  if (!widget->isActiveWindow() &&
2906  !((widget->windowFlags() & Qt::FramelessWindowHint) || (widget->windowType() == Qt::Tool))) {
2907  widget->activateWindow();
2908  if (widget->raiseOnClick())
2909  widget->raise();
2910  }
2911  }
2912  btnstate = mouseButtonState;
2913  widget = w;
2914  }
2915  }
2916 
2917  if (!widget) { // don't know this window
2918  if (!QWidget::mouseGrabber()
2919 #ifndef QT_NO_QWS_MANAGER
2920  && !QWSManager::grabbedMouse()
2921 #endif
2922  ) {
2923  qt_last_cursor = 0xffffffff; // cursor can be changed by another application
2924  }
2925 
2927  if (popup) {
2928 
2929  /*
2930  That is more than suboptimal. The real solution should
2931  do some keyevent and buttonevent translation, so that
2932  the popup still continues to work as the user expects.
2933  Unfortunately this translation is currently only
2934  possible with a known widget. I'll change that soon
2935  (Matthias).
2936  */
2937 
2938  // Danger - make sure we don't lock the server
2939  switch (event->type) {
2940  case QWSEvent::Mouse:
2941  case QWSEvent::Key:
2942  do {
2943  popup->close();
2944  } while ((popup = qApp->activePopupWidget()));
2945  return 1;
2946  }
2947  }
2948  if (event->type == QWSEvent::Mouse && *mouseInWidget) {
2950  (*mouseInWidget) = 0;
2951  }
2952  return -1;
2953  }
2954 
2955  if (app_do_modal) // modal event handling
2956  if (!qt_try_modal(widget, event)) {
2957  return 1;
2958  }
2959 
2960  if (widget->qwsEvent(event)) // send through widget filter
2961  return 1;
2962  switch (event->type) {
2963 
2964  case QWSEvent::Mouse: { // mouse event
2965  QWSMouseEvent *me = event->asMouse();
2967 
2968  // Translate a QWS event into separate move
2969  // and press/release events
2970  // Beware of reentrancy: we can enter a modal state
2971  // inside translateMouseEvent
2972 
2973  if (isMove) {
2974  QWSMouseEvent move = *me;
2975  move.simpleData.state = oldstate;
2976  widget->translateMouseEvent(&move, oldstate);
2977  }
2978  if ((mouse.state&Qt::MouseButtonMask) != (oldstate&Qt::MouseButtonMask)) {
2979  widget->translateMouseEvent(me, oldstate);
2980  }
2981 
2982  if (mouse.delta != 0)
2983  widget->translateWheelEvent(me);
2984 
2985  if (qt_button_down && (mouse_state & Qt::MouseButtonMask) == 0)
2986  qt_button_down = 0;
2987 
2988  break;
2989  }
2990  case QWSEvent::Key: // keyboard event
2991  if (keywidget) // should always exist
2992  keywidget->translateKeyEvent(static_cast<QWSKeyEvent*>(event), grabbed);
2993  break;
2994 
2995 #ifndef QT_NO_QWS_INPUTMETHODS
2996  case QWSEvent::IMEvent:
2997  if (keywidget) // should always exist
2998  QWSInputContext::translateIMEvent(keywidget, static_cast<QWSIMEvent*>(event));
2999  break;
3000 
3001  case QWSEvent::IMQuery:
3002  if (keywidget) // should always exist
3003  QWSInputContext::translateIMQueryEvent(keywidget, static_cast<QWSIMQueryEvent*>(event));
3004  break;
3005 
3006  case QWSEvent::IMInit:
3007  QWSInputContext::translateIMInitEvent(static_cast<QWSIMInitEvent*>(event));
3008  break;
3009 #endif
3010  case QWSEvent::Region:
3011  widget->translateRegionEvent(static_cast<QWSRegionEvent*>(event));
3012  break;
3013  case QWSEvent::Focus:
3014  if ((static_cast<QWSFocusEvent*>(event))->simpleData.get_focus) {
3015  if (widget == static_cast<QWidget *>(desktop()))
3016  return true; // not interesting
3017  if (activeWindow() != widget) {
3018  setActiveWindow(widget);
3020  static_cast<QETWidget *>(QApplicationPrivate::active_window)->repaintDecoration(desktop()->rect(), false);
3021  if (widget && !d->inPopupMode()) {
3022  QWidget *w = widget->focusWidget();
3023  while (w && w->focusProxy())
3024  w = w->focusProxy();
3025  if (w && (w->focusPolicy() != Qt::NoFocus))
3026  w->setFocus();
3027  else
3028  widget->QWidget::focusNextPrevChild(true);
3030  if (widget->focusWidget())
3031  widget->focusWidget()->setFocus();
3032  else
3033  widget->window()->setFocus();
3034  }
3035  }
3036  }
3037  } else { // lost focus
3038  if (widget == static_cast<QWidget *>(desktop()))
3039  return true; // not interesting
3042  setActiveWindow(0);
3043  qt_last_cursor = 0xffffffff;
3044  //QApplicationPrivate::active_window = 0;
3045  if (old)
3046  old->repaintDecoration(desktop()->rect(), false);
3047  /* activateWindow() sends focus events
3048  QApplication::setFocusWidget(0);
3049  */
3050  }
3051  }
3052  break;
3053 
3055  if (static_cast<QWidget *>(widget) == desktop())
3056  return true;
3057  switch ((static_cast<QWSWindowOperationEvent *>(event))->simpleData.op) {
3059  widget->show();
3060  break;
3062  widget->hide();
3063  break;
3065  widget->showMaximized();
3066  break;
3068  widget->showMinimized();
3069  break;
3071  widget->showNormal();
3072  break;
3075  break;
3076  }
3077  break;
3078 #ifndef QT_NO_QWSEMBEDWIDGET
3079  case QWSEvent::Embed:
3080  widget->translateEmbedEvent(static_cast<QWSEmbedEvent*>(event));
3081  break;
3082 #endif
3083  default:
3084  break;
3085  }
3086 
3087  return 0;
3088 }
void showMaximized()
Shows the widget maximized.
Definition: qwidget.cpp:3218
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
QByteArray fontName
Definition: qwsevent_qws.h:441
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
unsigned long WId
Definition: qwindowdefs.h:119
static bool translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e)
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
QPointer< QWidget > widget
void selectCursor(QWidget *w, unsigned int id)
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
static QWSDisplay * qwsDisplay()
QWSMouseEvent * asMouse()
Definition: qwsevent_qws.h:90
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
QCursor * curs
Definition: qwidget_p.h:254
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type)
int window()
Definition: qwsevent_qws.h:92
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isActiveWindow() const
The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux...
QClipboard * qt_clipboard
#define Q_D(Class)
Definition: qglobal.h:2482
struct QWSMouseEvent::SimpleData simpleData
QWidget * focusProxy() const
Returns the focus proxy, or 0 if there is no focus proxy.
Definition: qwidget.cpp:6561
void showNormal()
Restores the widget after it has been maximized or minimized.
Definition: qwidget.cpp:3250
The QPointer class is a template class that provides guarded pointers to QObject. ...
Definition: qpointer.h:54
bool translateKeyEvent(const QWSKeyEvent *, bool grab)
static QWidget * focus_widget
static QFontCache * instance()
Definition: qfont.cpp:2919
static void sendLocally(const QString &ch, const QString &msg, const QByteArray &data)
Client side: distribute received event to the QCop instance managing the channel. ...
static int mouse_y_root
static QWidget * activeModalWidget()
Returns the active modal widget.
void removeEngineForFont(const QByteArray &fontName)
Definition: qfont.cpp:3025
QWidgetPrivate * d_func()
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
#define qApp
void repaintDecoration(QRegion r, bool post)
bool translateWheelEvent(const QWSMouseEvent *me)
struct QWSPropertyNotifyEvent::SimpleData simpleData
static int mouse_x_root
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
struct QWSFontEvent::SimpleData simpleData
void translateEmbedEvent(const QWSEmbedEvent *event)
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
QWidget * qt_button_down
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
WId qt_last_cursor
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static int mouse_state
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool close_helper(CloseMode mode)
Definition: qwidget.cpp:8218
void show()
Shows the widget and its child widgets.
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
QRect * rectangles
Definition: qwsevent_qws.h:265
struct QWSScreenTransformationEvent::SimpleData simpleData
QRect rect() const
void showMinimized()
Shows the widget minimized, as an icon.
Definition: qwidget.cpp:3038
void hide()
Hides the widget.
Definition: qwidget.h:501
static bool translateIMEvent(QWidget *w, const QWSIMEvent *e)
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static Qt::MouseButtons mouseButtonState
QPoint mapFromParent(const QPoint &) const
Translates the parent widget coordinate pos to widget coordinates.
Definition: qwidget.cpp:4473
static QWidget * activePopupWidget()
Returns the active popup widget.
void setRects(const QRect *rect, int num)
Sets the region using the array of rectangles specified by rects and number.
Definition: qregion.cpp:4424
void qt_directpainter_embedevent(QDirectPainter *dp, const QWSEmbedEvent *e)
bool qws_overrideCursor
virtual bool qwsEventFilter(QWSEvent *)
This virtual function is only implemented under Qt for Embedded Linux.
struct QWSRegionEvent::SimpleData simpleData
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
bool translateRegionEvent(const QWSRegionEvent *)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual bool qwsEvent(QWSEvent *)
This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux...
Definition: qwidget.cpp:9993
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
static void setMaxWindowRect(const QRect &rect)
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QWidget * qt_pressGrab
bool translateMouseEvent(const QWSMouseEvent *, int oldstate)
The QClipboardEvent class provides the parameters used in a clipboard event.
Definition: qevent.h:695
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
QWExtra * extraData() const
Definition: qwidget_p.h:999
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
bool filterEvent(void *message, long *result)
Sends message through the event filter that was set by setEventFilter().
static bool app_do_modal
static QPointer< QWidget > * mouseInWidget
static bool qt_try_modal(QWidget *, QWSEvent *)
static bool translateIMInitEvent(const QWSIMInitEvent *e)
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
static void setScreenTransformation(int screenNo, int transformation)

◆ qwsSetCustomColors()

void QApplication::qwsSetCustomColors ( QRgb colorTable,
int  start,
int  numColors 
)

Set Qt for Embedded Linux custom color table.

Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. The remaining 40 colors may be used by setting a custom color table in the QWS master process before any clients connect.

colorTable is an array of up to 40 custom colors. start is the starting index (0-39) and numColors is the number of colors to be set (1-40).

This method is non-portable. It is available only in Qt for Embedded Linux.

Note
The custom colors will not be used by the default screen driver. To make use of the new colors, implement a custom screen driver, or use QDirectPainter.

Definition at line 3095 of file qapplication_qws.cpp.

3096 {
3097  if (start < 0 || start > 39) {
3098  qWarning("QApplication::qwsSetCustomColors: start < 0 || start > 39");
3099  return;
3100  }
3101  if (start + numColors > 40) {
3102  numColors = 40 - start;
3103  qWarning("QApplication::qwsSetCustomColors: Too many colors");
3104  }
3105  start += 216;
3106  for (int i = 0; i < numColors; i++) {
3107  qt_screen->set(start + i, qRed(colorTable[i]), qGreen(colorTable[i]),
3108  qBlue(colorTable[i]));
3109  }
3110 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
Q_CORE_EXPORT void qWarning(const char *,...)
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
virtual void set(unsigned int, unsigned int, unsigned int, unsigned int)

◆ restoreOverrideCursor()

void QApplication::restoreOverrideCursor ( )
static

Undoes the last setOverrideCursor().

If setOverrideCursor() has been called twice, calling restoreOverrideCursor() will activate the first cursor set. Calling this function a second time restores the original widgets' cursors.

See also
setOverrideCursor(), overrideCursor()

Definition at line 1419 of file qapplication_mac.mm.

Referenced by QApplicationPrivate::applyX11SpecificCommandLineArguments(), QOleDropTarget::Drop(), findRealWindow(), parseGeometry(), QGuiEventDispatcherWin32::processEvents(), QAxSelect::QAxSelect(), QTextBrowserPrivate::setSource(), QDragManager::~QDragManager(), and QWhatsThisPrivate::~QWhatsThisPrivate().

1420 {
1421  if (qApp->d_func()->cursor_list.isEmpty())
1422  return;
1423  qApp->d_func()->cursor_list.removeFirst();
1424 
1425 #ifdef QT_MAC_USE_COCOA
1427 #else
1428  if (qApp && qApp->activeWindow()) {
1429  const QCursor def(Qt::ArrowCursor);
1430  qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first());
1431  }
1432 #endif
1433 }
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
void qt_mac_set_cursor(const QCursor *)
Definition: qcursor_mac.mm:108
void qt_mac_update_cursor()
Definition: qcursor_mac.mm:201
#define qApp

◆ saveState()

void QApplication::saveState ( QSessionManager manager)
virtual

This function deals with Session Management{session management}.

It is invoked when the session manager wants the application to preserve its state for a future session.

For example, a text editor would create a temporary file that includes the current contents of its edit buffers, the location of the cursor and other aspects of the current editing session.

You should never exit the application within this function. Instead, the session manager may or may not do this afterwards, depending on the context. Futhermore, most session managers will very likely request a saved state immediately after the application has been started. This permits the session manager to learn about the application's restart policy.

Warning
Within this function, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details.
See also
isSessionRestored(), sessionId(), commitData(), {Session Management}

Definition at line 3668 of file qapplication.cpp.

3669 {
3670  emit saveStateRequest(manager);
3671 }
void saveStateRequest(QSessionManager &sessionManager)
This signal deals with Session Management{session management}.
#define emit
Definition: qobjectdefs.h:76

◆ saveStateRequest

void QApplication::saveStateRequest ( QSessionManager manager)
signal

This signal deals with Session Management{session management}.

Since
4.2

It is invoked when the session manager wants the application to preserve its state for a future session.

For example, a text editor would create a temporary file that includes the current contents of its edit buffers, the location of the cursor and other aspects of the current editing session.

You should never exit the application within this signal. Instead, the session manager may or may not do this afterwards, depending on the context. Futhermore, most session managers will very likely request a saved state immediately after the application has been started. This permits the session manager to learn about the application's restart policy.

Warning
Within this function, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details.
Note
You should use Qt::DirectConnection when connecting to this signal.
See also
isSessionRestored(), sessionId(), commitData(), {Session Management}

Referenced by saveState().

◆ sessionId()

QString QApplication::sessionId ( ) const

Returns the current Session Management{session's} identifier.

If the application has been restored from an earlier session, this identifier is the same as it was in that previous session. The session identifier is guaranteed to be unique both for different applications and for different instances of the same application.

See also
isSessionRestored(), sessionKey(), commitData(), saveState()

Definition at line 3487 of file qapplication.cpp.

3488 {
3489  Q_D(const QApplication);
3490  return d->session_id;
3491 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
#define Q_D(Class)
Definition: qglobal.h:2482

◆ sessionKey()

QString QApplication::sessionKey ( ) const

Returns the session key in the current Session Management{session}.

If the application has been restored from an earlier session, this key is the same as it was when the previous session ended.

The session key changes with every call of commitData() or saveState().

See also
isSessionRestored(), sessionId(), commitData(), saveState()

Definition at line 3493 of file qapplication.cpp.

3494 {
3495  Q_D(const QApplication);
3496  return d->session_key;
3497 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setActiveWindow()

void QApplication::setActiveWindow ( QWidget active)
static

Sets the active window to the active widget in response to a system event.

The function is called from the platform specific event handlers.

Warning
This function does not set the keyboard focus to the active widget. Call QWidget::activateWindow() instead.

It sets the activeWindow() and focusWidget() attributes and sends proper WindowActivate/WindowDeactivate and FocusIn/FocusOut events to all appropriate widgets. The window will then be painted in active state (e.g. cursors in line edits will blink), and it will have tool tips enabled.

See also
activeWindow(), QWidget::activateWindow()

Definition at line 2622 of file qapplication.cpp.

Referenced by QWidgetPrivate::deactivateWidgetCleanup(), QApplicationPrivate::globalEventProcessor(), onApplicationChangedActivation(), q_createNativeChildrenAndSetParent(), qt_cleanup(), QtWndProc(), and QX11EmbedWidget::x11Event().

2623 {
2624  QWidget* window = act?act->window():0;
2625 
2626  if (QApplicationPrivate::active_window == window)
2627  return;
2628 
2629 #ifndef QT_NO_GRAPHICSVIEW
2630  if (window && window->graphicsProxyWidget()) {
2631  // Activate the proxy's view->viewport() ?
2632  return;
2633  }
2634 #endif
2635 
2636  QWidgetList toBeActivated;
2637  QWidgetList toBeDeactivated;
2638 
2641  QWidgetList list = topLevelWidgets();
2642  for (int i = 0; i < list.size(); ++i) {
2643  QWidget *w = list.at(i);
2644  if (w->isVisible() && w->isActiveWindow())
2645  toBeDeactivated.append(w);
2646  }
2647  } else {
2648  toBeDeactivated.append(QApplicationPrivate::active_window);
2649  }
2650  }
2651 
2652 #if !defined(Q_WS_MAC)
2653  QWidget *previousActiveWindow = QApplicationPrivate::active_window;
2654 #endif
2656 
2659  QWidgetList list = topLevelWidgets();
2660  for (int i = 0; i < list.size(); ++i) {
2661  QWidget *w = list.at(i);
2662  if (w->isVisible() && w->isActiveWindow())
2663  toBeActivated.append(w);
2664  }
2665  } else {
2667  }
2668 
2669  }
2670 
2671  // first the activation/deactivation events
2672  QEvent activationChange(QEvent::ActivationChange);
2673  QEvent windowActivate(QEvent::WindowActivate);
2674  QEvent windowDeactivate(QEvent::WindowDeactivate);
2675 
2676 #if !defined(Q_WS_MAC)
2677  if (!previousActiveWindow) {
2678  QEvent appActivate(QEvent::ApplicationActivate);
2679  sendSpontaneousEvent(qApp, &appActivate);
2680  }
2681 #endif
2682 
2683  for (int i = 0; i < toBeActivated.size(); ++i) {
2684  QWidget *w = toBeActivated.at(i);
2685  sendSpontaneousEvent(w, &windowActivate);
2686  sendSpontaneousEvent(w, &activationChange);
2687  }
2688 
2689 #ifdef QT_MAC_USE_COCOA
2690  // In case the user clicked on a child window, we need to
2691  // reestablish the stacking order of the window so
2692  // it pops in front of other child windows in cocoa:
2693  qt_cocoaStackChildWindowOnTopOfOtherChildren(window);
2694 #endif
2695 
2696  for(int i = 0; i < toBeDeactivated.size(); ++i) {
2697  QWidget *w = toBeDeactivated.at(i);
2698  sendSpontaneousEvent(w, &windowDeactivate);
2699  sendSpontaneousEvent(w, &activationChange);
2700  }
2701 
2702 #if !defined(Q_WS_MAC)
2704  QEvent appDeactivate(QEvent::ApplicationDeactivate);
2705  sendSpontaneousEvent(qApp, &appDeactivate);
2706  }
2707 #endif
2708 
2709  if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
2710  // then focus events
2715  if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
2717  else {
2719  if (w) {
2721  } else {
2722  // If the focus widget is not in the activate_window, clear the focus
2724  if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
2726  else if (!QApplicationPrivate::active_window->isAncestorOf(w))
2728  }
2729  }
2730  }
2731  }
2732 }
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QWidget * active_window
QGraphicsProxyWidget * graphicsProxyWidget() const
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns ...
Definition: qwidget.cpp:12939
static QStyle * style()
Returns the application&#39;s style object.
static QWidget * focus_widget
NSWindow * window
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason)
#define qApp
static QWidgetList * popupWidgets
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
const char * styleHint(const QFontDef &request)
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static QWidget * focusNextPrevChild_helper(QWidget *toplevel, bool next)
internal Helper function that returns the new focus widget, but does not set the focus reason...
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ setArgs()

void QApplication::setArgs ( int  argc,
char **  argv 
)
protected
Warning
This function is not part of the public interface.

Definition at line 3772 of file qapplication_qws.cpp.

3773 {
3774  Q_D(QApplication);
3775  d->argc = c;
3776  d->argv = v;
3777 }
double d
Definition: qnumeric_p.h:62
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setAutoMaximizeThreshold

void QApplication::setAutoMaximizeThreshold ( const int  threshold)
slot

Definition at line 1402 of file qapplication.cpp.

1403 {
1405 }
static int autoMaximizeThreshold

◆ setAutoSipEnabled

void QApplication::setAutoSipEnabled ( const bool  enabled)
slot

Definition at line 1413 of file qapplication.cpp.

1414 {
1416 }
static bool autoSipEnabled
#define enabled

◆ setColorSpec()

void QApplication::setColorSpec ( int  spec)
static

Sets the color specification for the application to spec.

The color specification controls how the application allocates colors when run on a display with a limited amount of colors, e.g. 8 bit / 256 color displays.

The color specification must be set before you create the QApplication object.

The options are:

  • QApplication::NormalColor. This is the default color allocation strategy. Use this option if your application uses buttons, menus, texts and pixmaps with few colors. With this option, the application uses system global colors. This works fine for most applications under X11, but on the Windows platform, it may cause dithering of non-standard colors.
  • QApplication::CustomColor. Use this option if your application needs a small number of custom colors. On X11, this option is the same as NormalColor. On Windows, Qt creates a Windows palette, and allocates colors to it on demand.
  • QApplication::ManyColor. Use this option if your application is very color hungry, e.g., it requires thousands of colors.

    Under X11 the effect is:

    • For 256-color displays which have at best a 256 color true color visual, the default visual is used, and colors are allocated from a color cube. The color cube is the 6x6x6 (216 color) "Web palette" (the red, green, and blue components always have one of the following values: 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors can be changed by the -ncols option. The user can force the application to use the true color visual with the -visual option.
    • For 256-color displays which have a true color visual with more than 256 colors, use that visual. Silicon Graphics X servers this feature, for example. They provide an 8 bit visual by default but can deliver true color when asked.

    On Windows, Qt creates a Windows palette, and fills it with a color cube.

Be aware that the CustomColor and ManyColor choices may lead to colormap flashing: The foreground application gets (most) of the available colors, while the background windows will look less attractive.

Example:

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
...
return app.exec();
}
See also
colorSpec()

Definition at line 1766 of file qapplication.cpp.

Referenced by QApplicationPrivate::qt_mac_apply_settings(), and QApplicationPrivate::x11_apply_settings().

1767 {
1768  if (qApp)
1769  qWarning("QApplication::setColorSpec: This function must be "
1770  "called before the QApplication object is created");
1772 }
#define qApp
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setCursorFlashTime()

void QApplication::setCursorFlashTime ( int  msecs)
static

◆ setDesktopSettingsAware()

void QApplication::setDesktopSettingsAware ( bool  on)
static

Sets whether Qt should use the system's standard colors, fonts, etc., to on.

By default, this is true.

This function must be called before creating the QApplication object, like this:

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
...
return app.exec();
}
See also
desktopSettingsAware()

Definition at line 3360 of file qapplication.cpp.

3361 {
3363 }
static bool obey_desktop_settings

◆ setDoubleClickInterval()

void QApplication::setDoubleClickInterval ( int  ms)
static

◆ setEffectEnabled()

void QApplication::setEffectEnabled ( Qt::UIEffect  effect,
bool  enable = true 
)
static

Enables the UI effect effect if enable is true, otherwise the effect will not be used.

Note
All effects are disabled on screens running at less than 16-bit color depth.
See also
isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware()

Definition at line 2842 of file qapplication_mac.mm.

Referenced by QApplicationPrivate::qt_mac_apply_settings(), qt_set_x11_resources(), QETWidget::translateCloseEvent(), QETWidget::updateRegion(), and QApplicationPrivate::x11_apply_settings().

2843 {
2844  switch (effect) {
2845  case Qt::UI_FadeMenu:
2847  break;
2848  case Qt::UI_AnimateMenu:
2850  break;
2851  case Qt::UI_FadeTooltip:
2853  break;
2854  case Qt::UI_AnimateTooltip:
2856  break;
2857  case Qt::UI_AnimateCombo:
2859  break;
2860  case Qt::UI_AnimateToolBox:
2862  break;
2863  case Qt::UI_General:
2865  break;
2866  default:
2868  break;
2869  }
2870 
2871  if (enable)
2873 }
static bool fade_tooltip
static bool animate_ui
static bool animate_combo
static bool animate_tooltip
static bool animate_toolbox
static bool animate_menu

◆ setFont()

void QApplication::setFont ( const QFont font,
const char *  className = 0 
)
static

Changes the default application font to font.

Use the two-argument overload instead.

If className is passed, the change applies only to classes that inherit className (as reported by QObject::inherits()).

On application start-up, the default font depends on the window system. It can vary depending on both the window system version and the locale. This function lets you override the default font; but overriding may be a bad idea because, for example, some locales need extra large fonts to support their special characters.

Warning
Do not use this function in conjunction with Qt Style Sheets. The font of an application can be customized using the "font" style sheet property. To set a bold font for all QPushButtons, set the application styleSheet() as "QPushButton { font: bold }"
See also
font(), fontMetrics(), QWidget::setFont()

Definition at line 2075 of file qapplication.cpp.

Referenced by QApplicationPrivate::qt_mac_apply_settings(), qt_set_qws_resources(), qt_set_windows_font_resources(), QFont::resolve(), QToolTip::setFont(), and QApplicationPrivate::setSystemFont().

2076 {
2077  bool all = false;
2078  FontHash *hash = app_fonts();
2079  if (!className) {
2080  QMutexLocker locker(applicationFontMutex());
2083  else
2085  if (hash && hash->size()) {
2086  all = true;
2087  hash->clear();
2088  }
2089  } else if (hash) {
2090  hash->insert(className, font);
2091  }
2093  // Send ApplicationFontChange to qApp itself, and to the widgets.
2096 
2098  for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
2099  register QWidget *w = *it;
2100  if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
2101  sendEvent(w, &e);
2102  }
2103 
2104 #ifndef QT_NO_GRAPHICSVIEW
2105  // Send to all scenes as well.
2106  QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
2108  it != scenes.constEnd(); ++it) {
2110  }
2111 #endif //QT_NO_GRAPHICSVIEW
2112  }
2116  else
2118  }
2119 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
void clear()
Removes all items from the hash.
Definition: qhash.h:574
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
bool isCopyOf(const QFont &) const
Returns true if this font and f are copies of each other, i.e.
Definition: qfont.cpp:1963
static QFont * sys_font
const char * className
Definition: qwizard.cpp:137
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static QFont font()
Returns the default application font.
#define qApp
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static QFont * app_font
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
static QFont * set_font
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ setGlobalStrut()

void QApplication::setGlobalStrut ( const QSize strut)
static

◆ setGraphicsSystem()

void QApplication::setGraphicsSystem ( const QString system)
static

Sets the default graphics backend to system, which will be used for on-screen widgets and QPixmaps.

Since
4.5

The available systems are "native", "raster" and "opengl".

There are several ways to set the graphics backend, in order of decreasing precedence:

If the highest precedence switch sets an invalid name, the error will be ignored and the default backend will be used.

Warning
This function is only effective before the QApplication constructor is called.
Note
The "opengl" option is currently experimental.

Definition at line 1684 of file qapplication.cpp.

Referenced by QMeeGoGraphicsSystem::switchToMeeGo(), and QMeeGoGraphicsSystem::switchToRaster().

1685 {
1686 #ifdef Q_WS_QPA
1687  Q_UNUSED(system);
1688 #else
1689 # ifdef QT_GRAPHICSSYSTEM_RUNTIME
1693  r->setGraphicsSystem(system);
1694  } else
1695 # endif
1697 #endif
1698 }
void setGraphicsSystem(const QString &name)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString graphics_system_name
static QGraphicsSystem * graphics_system
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setInputContext()

void QApplication::setInputContext ( QInputContext inputContext)

This function replaces the QInputContext instance used by the application with inputContext.

Qt takes ownership of the given inputContext.

See also
inputContext()

Definition at line 5701 of file qapplication.cpp.

5702 {
5703  if (inputContext == QApplicationPrivate::inputContext)
5704  return;
5705  if (!inputContext) {
5706  qWarning("QApplication::setInputContext: called with 0 input context");
5707  return;
5708  }
5712 }
QInputContext * inputContext() const
Returns the QInputContext instance used by the application.
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
Q_CORE_EXPORT void qWarning(const char *,...)
static QInputContext * inputContext

◆ setKeyboardInputInterval()

void QApplication::setKeyboardInputInterval ( int  ms)
static

◆ setLayoutDirection()

void QApplication::setLayoutDirection ( Qt::LayoutDirection  direction)
static

Definition at line 3804 of file qapplication.cpp.

Referenced by event(), and QApplicationPrivate::process_cmdline().

3805 {
3807  return;
3808 
3810 
3811  QWidgetList list = topLevelWidgets();
3812  for (int i = 0; i < list.size(); ++i) {
3813  QWidget *w = list.at(i);
3815  sendEvent(w, &ev);
3816  }
3817 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static Qt::LayoutDirection layout_direction
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
Qt::LayoutDirection direction

◆ setOverrideCursor()

void QApplication::setOverrideCursor ( const QCursor cursor)
static

Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is false).

Sets the application override cursor to cursor.

Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.

This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.

Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the curently active application override cursor.

Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.

Example:

See also
overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), QWidget::setCursor()

Definition at line 1407 of file qapplication_mac.mm.

Referenced by QApplicationPrivate::applyX11SpecificCommandLineArguments(), changeOverrideCursor(), parseGeometry(), QGuiEventDispatcherWin32::processEvents(), QAxSelect::QAxSelect(), QWhatsThisPrivate::QWhatsThisPrivate(), and QTextBrowserPrivate::setSource().

1408 {
1409  qApp->d_func()->cursor_list.prepend(cursor);
1410 
1411 #ifdef QT_MAC_USE_COCOA
1413 #else
1414  if (qApp && qApp->activeWindow())
1415  qt_mac_set_cursor(&qApp->d_func()->cursor_list.first());
1416 #endif
1417 }
void qt_mac_set_cursor(const QCursor *)
Definition: qcursor_mac.mm:108
void qt_mac_update_cursor()
Definition: qcursor_mac.mm:201
#define qApp

◆ setPalette()

void QApplication::setPalette ( const QPalette palette,
const char *  className = 0 
)
static

Changes the default application palette to palette.

Use the two-argument overload instead.

If className is passed, the change applies only to widgets that inherit className (as reported by QObject::inherits()). If className is left 0, the change affects all widgets, thus overriding any previously set class specific palettes.

The palette may be changed according to the current GUI style in QStyle::polish().

Warning
Do not use this function in conjunction with Qt Style Sheets. When using style sheets, the palette of a widget can be customized using the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color".
Note
Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for the Windows XP, Windows Vista, and Mac OS X styles.
See also
QWidget::setPalette(), palette(), QStyle::polish()

Definition at line 1941 of file qapplication.cpp.

Referenced by QApplicationPrivate::initializeWidgetPaletteHash(), QApplicationPrivate::qt_mac_apply_settings(), setStyle(), QApplicationPrivate::setSystemPalette(), style(), and QGtkStyleUpdateScheduler::updateTheme().

1942 {
1943  QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);
1944 }
const char * className
Definition: qwizard.cpp:137
static void setPalette_helper(const QPalette &palette, const char *className, bool clearWidgetPaletteHash)

◆ setQuitOnLastWindowClosed()

void QApplication::setQuitOnLastWindowClosed ( bool  quit)
static

Definition at line 5328 of file qapplication.cpp.

Referenced by main().

5329 {
5331 }
static void quit()
Tells the application to exit with return code 0 (success).
static bool quitOnLastWindowClosed

◆ setStartDragDistance()

void QApplication::setStartDragDistance ( int  l)
static

Definition at line 3715 of file qapplication.cpp.

3716 {
3717  drag_distance = l;
3718 }
static int drag_distance
QFactoryLoader * l

◆ setStartDragTime()

void QApplication::setStartDragTime ( int  ms)
static

Definition at line 3679 of file qapplication.cpp.

3680 {
3681  drag_time = ms;
3682 }
static int drag_time

◆ setStyle() [1/2]

void QApplication::setStyle ( QStyle style)
static

Sets the application's GUI style to style.

Ownership of the style object is transferred to QApplication, so QApplication will delete the style object on application exit or when a new style is set and the old style is still the parent of the application object.

Example usage:

When switching application styles, the color palette is set back to the initial colors or the system defaults. This is necessary since certain styles have to adapt the color palette to be fully style-guide compliant.

Setting the style before a palette has been set, i.e., before creating QApplication, will cause the application to use QStyle::standardPalette() for the palette.

Warning
Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.
See also
style(), QStyle, setPalette(), desktopSettingsAware()

Definition at line 1534 of file qapplication.cpp.

Referenced by QApplicationPrivate::qt_mac_apply_settings(), setStyle(), setStyleSheet(), and QApplicationPrivate::x11_apply_settings().

1535 {
1536  if (!style || style == QApplicationPrivate::app_style)
1537  return;
1538 
1540 
1541  // clean up the old style
1544  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
1545  register QWidget *w = *it;
1546  if (!(w->windowType() == Qt::Desktop) && // except desktop
1547  w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
1549  }
1550  }
1551  }
1553  }
1554 
1555  QStyle *old = QApplicationPrivate::app_style; // save
1556 
1557 #ifndef QT_NO_STYLE_STYLESHEET
1558  if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
1559  // we have a stylesheet already and a new style is being set
1560  QStyleSheetStyle *newProxy = new QStyleSheetStyle(style);
1561  style->setParent(newProxy);
1562  QApplicationPrivate::app_style = newProxy;
1563  } else
1564 #endif // QT_NO_STYLE_STYLESHEET
1566  QApplicationPrivate::app_style->setParent(qApp); // take ownership
1567 
1568  // take care of possible palette requirements of certain gui
1569  // styles. Do it before polishing the application since the style
1570  // might call QApplication::setPalette() itself
1573  } else if (QApplicationPrivate::sys_pal) {
1575  QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false);
1576  } else if (!QApplicationPrivate::sys_pal) {
1577  // Initialize the sys_pal if it hasn't happened yet...
1579  }
1580 
1581  // initialize the application with the new style
1583 
1584  // re-polish existing widgets if necessary
1586  for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
1587  register QWidget *w = *it1;
1590  QApplicationPrivate::app_style->polish(w); // repolish
1591 #ifndef QT_NO_STYLE_STYLESHEET
1592  else
1593  w->setStyleSheet(w->styleSheet()); // touch
1594 #endif
1595  }
1596  }
1597 
1598  for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
1599  register QWidget *w = *it2;
1600  if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
1602  QApplication::sendEvent(w, &e);
1603 #ifdef QT3_SUPPORT
1604  if (old)
1605  w->styleChange(*old);
1606 #endif
1607  w->update();
1608  }
1609  }
1610  }
1611 
1612 #ifndef QT_NO_STYLE_STYLESHEET
1613  if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) {
1614  oldProxy->deref();
1615  } else
1616 #endif
1617  if (old && old->parent() == qApp) {
1618  delete old;
1619  }
1620 
1625  }
1626 }
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
#define it(className, varName)
static QPalette * set_pal
static void initializeWidgetPaletteHash()
virtual void styleChange(QStyle &)
Definition: qwidget.cpp:12000
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
static QStyle * style()
Returns the application&#39;s style object.
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
QStyle * style() const
Definition: qwidget.cpp:2742
static QWidget * focus_widget
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
static bool isEmpty(const char *str)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
static void setPalette_helper(const QPalette &palette, const char *className, bool clearWidgetPaletteHash)
static QStyle * app_style
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QPalette * sys_pal
QString styleSheet
the widget&#39;s style sheet
Definition: qwidget.h:220
static QString styleSheet
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
static void setSystemPalette(const QPalette &pal)
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
void setStyleSheet(const QString &styleSheet)
Definition: qwidget.cpp:2709
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ setStyle() [2/2]

QStyle * QApplication::setStyle ( const QString style)
static

Requests a QStyle object for style from the QStyleFactory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The string must be one of the QStyleFactory::keys(), typically one of "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style names are case insensitive.

Returns 0 if an unknown style is passed, otherwise the QStyle object returned is set as the application's GUI style.

Warning
To ensure that the application's style is set correctly, it is best to call this function before the QApplication constructor, if possible.

Definition at line 1647 of file qapplication.cpp.

1648 {
1649  QStyle *s = QStyleFactory::create(style);
1650  if (!s)
1651  return 0;
1652 
1653  setStyle(s);
1654  return s;
1655 }
static void setStyle(QStyle *)
Sets the application&#39;s GUI style to style.
static QStyle * create(const QString &)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68

◆ setStyleSheet

void QApplication::setStyleSheet ( const QString sheet)
slot

Definition at line 1430 of file qapplication.cpp.

1431 {
1434  if (styleSheet.isEmpty()) { // application style sheet removed
1435  if (!proxy)
1436  return; // there was no stylesheet before
1437  setStyle(proxy->base);
1438  } else if (proxy) { // style sheet update, just repolish
1439  proxy->repolish(qApp);
1440  } else { // stylesheet set the first time
1443  setStyle(newProxy);
1444  }
1445 }
static void setStyle(QStyle *)
Sets the application&#39;s GUI style to style.
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
static QStyle * app_style
static QString styleSheet
void repolish(QWidget *widget)
QString styleSheet() const

◆ setWheelScrollLines()

void QApplication::setWheelScrollLines ( int  n)
static

◆ setWindowIcon()

void QApplication::setWindowIcon ( const QIcon icon)
static

Definition at line 2155 of file qapplication.cpp.

2156 {
2161 #ifdef Q_WS_MAC
2162  void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp
2165 #endif
2168  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
2169  register QWidget *w = *it;
2170  if (w->isWindow())
2171  sendEvent(w, &e);
2172  }
2173  }
2174 }
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
static QIcon * app_icon
void qt_mac_set_app_icon(const QPixmap &pixmap)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ startDragDistance()

static int QApplication::startDragDistance ( )
static

◆ startDragTime()

static int QApplication::startDragTime ( )
static

◆ style()

QStyle * QApplication::style ( )
static

Returns the application's style object.

See also
setStyle(), QStyle

Definition at line 1454 of file qapplication.cpp.

Referenced by QStyleSheetStyle::baseStyle(), QItemDelegate::check(), QDialogButtonBoxPrivate::createButton(), QItemDelegate::doLayout(), QItemDelegate::drawCheck(), QItemDelegate::drawDisplay(), QItemDelegate::drawFocus(), drawTextItemDecoration(), QStyledItemDelegate::editorEvent(), QWizardPrivate::ensureButton(), QFileIconProviderPrivate::getIcon(), QTextControl::getPaintContext(), QFormLayoutPrivate::getStyle(), QTabBarPrivate::layoutTabs(), QDecorationStyled::paint(), QStyledItemDelegate::paint(), QColumnViewDelegate::paint(), QSvgIconEngine::pixmap(), QPixmapIconEngine::pixmap(), qt_mac_update_os_settings(), QtWndProc(), QDecorationStyled::region(), setActiveWindow(), QTextControl::setOverwriteMode(), setStyle(), QSystemTrayIconPrivate::showMessage_sys(), QStyledItemDelegate::sizeHint(), QMessageBoxPrivate::standardIcon(), QGraphicsWidget::style(), QGraphicsScene::style(), QWidget::style(), QGraphicsGridLayoutPrivate::styleInfo(), QGraphicsLinearLayoutPrivate::styleInfo(), QGraphicsAnchorLayoutPrivate::styleInfo(), QItemDelegate::textRectangle(), QTextControl::timerEvent(), QDecorationStyled::titleBarHeight(), QStyledItemDelegate::updateEditorGeometry(), and QMessageBoxPrivate::updateSize().

1455 {
1458  if (!qt_is_gui_used) {
1459  Q_ASSERT(!"No style available in non-gui applications!");
1460  return 0;
1461  }
1462 
1464  // Compile-time search for default style
1465  //
1466  QString style;
1467 #ifdef QT_BUILD_INTERNAL
1468  QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
1469 #else
1470  QString envStyle;
1471 #endif
1474  } else if (!envStyle.isEmpty()) {
1475  style = envStyle;
1476  } else {
1478  }
1479 
1480  QStyle *&app_style = QApplicationPrivate::app_style;
1481  app_style = QStyleFactory::create(style);
1482  if (!app_style) {
1483  QStringList styles = QStyleFactory::keys();
1484  for (int i = 0; i < styles.size(); ++i) {
1485  if ((app_style = QStyleFactory::create(styles.at(i))))
1486  break;
1487  }
1488  }
1489  if (!app_style) {
1490  Q_ASSERT(!"No styles available!");
1491  return 0;
1492  }
1493  }
1494  // take ownership of the style
1496 
1499  if (QApplicationPrivate::set_pal) // repolish set palette with the new style
1501 
1502 #ifndef QT_NO_STYLE_STYLESHEET
1504  qApp->setStyleSheet(QApplicationPrivate::styleSheet);
1505  } else
1506 #endif
1508 
1510 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static void setPalette(const QPalette &, const char *className=0)
Changes the default application palette to palette.
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
static QPalette * set_pal
static QStyle * create(const QString &)
static QStyle * style()
Returns the application&#39;s style object.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
static QStringList keys()
Returns the list of valid keys, i.e.
static bool isEmpty(const char *str)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QStyle * app_style
static QPalette * sys_pal
static QString styleSheet
static QString desktopStyleKey()
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
static void setSystemPalette(const QPalette &pal)
static QString styleOverride
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
bool qt_is_gui_used

◆ styleSheet()

QString QApplication::styleSheet ( ) const

Referenced by setAutoSipEnabled(), and setStyleSheet().

◆ syncX()

void QApplication::syncX ( )
static

Synchronizes with the X server in the X11 implementation.

This normally takes some time. Does nothing on other platforms.

Definition at line 3029 of file qapplication_x11.cpp.

Referenced by event(), QWidgetResizeHandler::mouseMoveEvent(), QWidgetBackingStore::showYellowThing(), and QETWidget::translateConfigEvent().

3030 {
3031  if (X11->display)
3032  XSync(X11->display, False); // don't discard events
3033 }
#define X11
Definition: qt_x11_p.h:724

◆ topLevelAt() [1/2]

QWidget * QApplication::topLevelAt ( const QPoint p)
static

Returns the top-level widget at the given point; returns 0 if there is no such widget.

Definition at line 1441 of file qapplication_mac.mm.

Referenced by QX11Data::findClientWindow(), parseGeometry(), qt_cleanup(), qt_qpa_set_cursor(), qt_win_getKeyboardModifiers(), QApplicationPrivate::translateRawTouchEvent(), and widgetAt().

1442 {
1443 #ifndef QT_MAC_USE_COCOA
1444  QWidget *widget;
1445  qt_mac_window_at(p.x(), p.y(), &widget);
1446  return widget;
1447 #else
1448  // Use a cache to avoid iterate through the whole list of windows for all
1449  // calls to to topLevelAt. We e.g. do this for each and every mouse
1450  // move since we need to find the widget under mouse:
1452  return topLevelAt_cache;
1453 
1454  // INVARIANT: Cache miss. Go through the list if windows instead:
1456  NSPoint cocoaPoint = flipPoint(p);
1457  NSInteger windowCount;
1458  NSCountWindows(&windowCount);
1459  if (windowCount <= 0)
1460  return 0; // There's no window to find!
1461 
1462  QVarLengthArray<NSInteger> windowList(windowCount);
1463  NSWindowList(windowCount, windowList.data());
1464  int firstQtWindowFound = -1;
1465  for (int i = 0; i < windowCount; ++i) {
1466  NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
1467  if (window) {
1468  QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
1469  if (candidateWindow && firstQtWindowFound == -1)
1470  firstQtWindowFound = i;
1471 
1472  if (NSPointInRect(cocoaPoint, [window frame])) {
1473  // Check to see if there's a hole in the window where the mask is.
1474  // If there is, we should just continue to see if there is a window below.
1475  if (candidateWindow && !candidateWindow->mask().isEmpty()) {
1476  QPoint localPoint = candidateWindow->mapFromGlobal(p);
1477  if (!candidateWindow->mask().contains(localPoint))
1478  continue;
1479  else
1480  return candidateWindow;
1481  } else {
1482  if (i == firstQtWindowFound) {
1483  // The cache will only work when the window under mouse is
1484  // top most (that is, not partially obscured by other windows.
1485  // And we only set it if no mask is present to optimize for the common case:
1486  topLevelAt_cache = candidateWindow;
1487  }
1488  return candidateWindow;
1489  }
1490  }
1491  }
1492  }
1493 
1494  topLevelAt_cache = 0;
1495  return 0;
1496 #endif
1497 }
QPointer< QWidget > widget
static short qt_mac_window_at(int x, int y, QWidget **w=0)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
QPointF flipPoint(const NSPoint &p)
NSWindow * window
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
Definition: qregion.cpp:4104
QPointer< QWidget > topLevelAt_cache
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106
struct CGPoint NSPoint
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ topLevelAt() [2/2]

QWidget * QApplication::topLevelAt ( int  x,
int  y 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the top-level widget at the point ({x}, {y}); returns 0 if there is no such widget.

Definition at line 196 of file qapplication.h.

Referenced by topLevelAt().

196 { return topLevelAt(QPoint(x, y)); }
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ topLevelWidgets()

QWidgetList QApplication::topLevelWidgets ( )
static

Returns a list of the top-level widgets (windows) in the application.

Note
Some of the top-level widgets may be hidden, for example a tooltip if no tooltip is currently shown.

Example:

void showAllHiddenTopLevelWidgets()
{
if (widget->isHidden())
widget->show();
}
}
See also
allWidgets(), QWidget::isWindow(), QWidget::isHidden()

Definition at line 2188 of file qapplication.cpp.

Referenced by QDialog::adjustPosition(), QApplicationPrivate::canQuit(), QKeyMapper::changeKeyboard(), QWidgetPrivate::close_helper(), closeAllWindows(), commitData(), QApplicationPrivate::enterModal(), event(), QX11Data::findClientWindow(), findWindowThatShouldDisplayMenubar(), QEventDispatcherMac::flush(), QApplicationPrivate::globalEventProcessor(), QApplicationPrivate::leaveModal(), QWhatsThisPrivate::notifyToplevels(), qt_cleanup(), qt_mac_should_disable_menu(), QtWndProc(), setActiveWindow(), setLayoutDirection(), QApplicationPrivate::setMaxWindowRect(), QApplicationPrivate::setScreenTransformation(), QPlatformScreen::topLevelAt(), and topLevelWidgets().

2189 {
2190  QWidgetList list;
2192 
2193  for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
2194  QWidget *w = *it;
2195  if (w->isWindow() && w->windowType() != Qt::Desktop)
2196  list.append(w);
2197  }
2198  return list;
2199 }
static QWidgetList allWidgets()
Returns a list of all the widgets in the application.
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ type()

QApplication::Type QApplication::type ( )
static

◆ wheelScrollLines()

static int QApplication::wheelScrollLines ( )
static

◆ widgetAt() [1/2]

QWidget * QApplication::widgetAt ( const QPoint point)
static

Returns the widget at global screen position point, or 0 if there is no Qt widget there.

This function can be slow.

See also
QCursor::pos(), QWidget::grabMouse(), QWidget::grabKeyboard()

Definition at line 1242 of file qapplication.cpp.

Referenced by QCompleter::eventFilter(), flipPoint(), QApplicationPrivate::globalEventProcessor(), QApplicationPrivate::leaveModal_sys(), make_widget_eventUPP(), make_win_eventUPP(), parseGeometry(), qstring_to_xtp(), qt_mac_update_cursor(), qt_mac_update_cursor_at_global_pos(), qt_qpa_set_cursor(), QtWndProc(), QWhatsThisPrivate::QWhatsThisPrivate(), QApplicationPrivate::sendMouseEvent(), QWSServerPrivate::sendMouseEventUnfiltered(), QCursor::setPos(), QETWidget::translateMouseEvent(), QETWidget::translateTabletEvent(), QETWidget::translateWheelEvent(), and x11EventFilter().

1243 {
1245  if (!window)
1246  return 0;
1247 
1248  QWidget *child = 0;
1249 
1251  child = window->childAt(window->mapFromGlobal(p));
1252 
1253  if (child)
1254  return child;
1255 
1257  //shoot a hole in the widget and try once again,
1258  //suboptimal on Qt for Embedded Linux where we do
1259  //know the stacking order of the toplevels.
1260  int x = p.x();
1261  int y = p.y();
1262  QRegion oldmask = window->mask();
1263  QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
1264  QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
1265  - QRegion(wpoint.x(), wpoint.y(), 1, 1);
1266  window->setMask(newmask);
1267  QWidget *recurse = 0;
1268  if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
1269  recurse = widgetAt(x, y);
1270  if (oldmask.isEmpty())
1271  window->clearMask();
1272  else
1273  window->setMask(oldmask);
1274  return recurse;
1275  }
1276  return window;
1277 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
NSWindow * window
void clearMask()
Removes any mask set by setMask().
Definition: qwidget.cpp:13324
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ widgetAt() [2/2]

QWidget * QApplication::widgetAt ( int  x,
int  y 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the widget at global screen position (x, y), or 0 if there is no Qt widget there.

Definition at line 194 of file qapplication.h.

Referenced by widgetAt().

194 { return widgetAt(QPoint(x, y)); }
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ windowIcon()

static QIcon QApplication::windowIcon ( )
static

◆ winFocus()

void QApplication::winFocus ( QWidget widget,
bool  gotFocus 
)
Warning
This function is not part of the public interface.
Since
4.1

If gotFocus is true, widget will become the active window. Otherwise the active window is reset to 0.

Definition at line 1407 of file qapplication_win.cpp.

1408 {
1409  if (d_func()->inPopupMode()) // some delayed focus event to ignore
1410  return;
1411  if (gotFocus) {
1412  setActiveWindow(widget);
1414  && (QApplicationPrivate::active_window->windowType() == Qt::Dialog)) {
1415  // raise the entire application, not just the dialog
1417 #ifndef Q_WS_WINCE
1418  while(mw->parentWidget() && (mw->windowType() == Qt::Dialog))
1419  mw = mw->parentWidget()->window();
1421  SetWindowPos(mw->internalWinId(), HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1422 #else
1423  // On Desktop Windows, we set the first parent of the dialog on top
1424  // Child windows will be automatically set above again.
1425  // On Windows CE we pass no parent in CreateWindowEx as otherwise
1426  // dialogs get embedded into the parent window. Thus we need to
1427  // manually iterate and reactivate all windows from bottom up.
1428  QList<QWidget*> raiseList;
1429  raiseList.push_back(mw);
1430  while(mw->parentWidget() && (mw->windowType() == Qt::Dialog)) {
1431  mw = mw->parentWidget()->window();
1432  raiseList.push_back(mw);
1433  }
1434  while(!raiseList.isEmpty()) {
1435  mw = raiseList.takeLast();
1437  HWND state = HWND_TOP;
1439  state = HWND_BOTTOM;
1440  else if (mw->windowFlags() & Qt::WindowStaysOnTopHint)
1441  state = HWND_TOPMOST;
1442  SetWindowPos(mw->internalWinId(), state, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1443  }
1444  }
1445 #endif
1446  }
1447  } else {
1448  setActiveWindow(0);
1449  }
1450 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QWidget * active_window
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define HWND_TOPMOST
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ winMouseButtonUp()

void QApplication::winMouseButtonUp ( )
static
Warning
This function is not part of the public interface.

Definition at line 3033 of file qapplication_win.cpp.

3034 {
3035  qt_button_down = 0;
3037 }
static void releaseAutoCapture()
QWidget * qt_button_down

◆ x11ClientMessage()

int QApplication::x11ClientMessage ( QWidget w,
XEvent event,
bool  passive_only 
)
virtual
Warning
This function is not part of the public interface.

Definition at line 3149 of file qapplication_x11.cpp.

3150 {
3151  if (w && !w->internalWinId())
3152  return 0;
3153  QETWidget *widget = (QETWidget*)w;
3154  if (event->xclient.format == 32 && event->xclient.message_type) {
3155  if (event->xclient.message_type == ATOM(WM_PROTOCOLS)) {
3156  Atom a = event->xclient.data.l[0];
3157  if (a == ATOM(WM_DELETE_WINDOW)) {
3158  if (passive_only) return 0;
3159  widget->translateCloseEvent(event);
3160  }
3161  else if (a == ATOM(WM_TAKE_FOCUS)) {
3162  if ((ulong) event->xclient.data.l[1] > X11->time)
3163  X11->time = event->xclient.data.l[1];
3164  QWidget *amw = activeModalWidget();
3165  if (amw && amw->testAttribute(Qt::WA_X11DoNotAcceptFocus))
3166  amw = 0;
3167  if (amw && !QApplicationPrivate::tryModalHelper(widget, 0)) {
3168  QWidget *p = amw->parentWidget();
3169  while (p && p != widget)
3170  p = p->parentWidget();
3171  if (!p || !X11->net_supported_list)
3172  amw->raise(); // help broken window managers
3173  amw->activateWindow();
3174  }
3175 #ifndef QT_NO_WHATSTHIS
3176  } else if (a == ATOM(_NET_WM_CONTEXT_HELP)) {
3178 #endif // QT_NO_WHATSTHIS
3179  } else if (a == ATOM(_NET_WM_PING)) {
3180  // avoid send/reply loops
3181  Window root = RootWindow(X11->display, w->x11Info().screen());
3182  if (event->xclient.window != root) {
3183  event->xclient.window = root;
3184  XSendEvent(event->xclient.display, event->xclient.window,
3185  False, SubstructureNotifyMask|SubstructureRedirectMask, event);
3186  }
3187 #ifndef QT_NO_XSYNC
3188  } else if (a == ATOM(_NET_WM_SYNC_REQUEST)) {
3189  const ulong timestamp = (const ulong) event->xclient.data.l[1];
3190  if (timestamp > X11->time)
3191  X11->time = timestamp;
3192  if (QTLWExtra *tlw = w->d_func()->maybeTopData()) {
3193  if (timestamp == CurrentTime || timestamp > tlw->syncRequestTimestamp) {
3194  tlw->syncRequestTimestamp = timestamp;
3195  tlw->newCounterValueLo = event->xclient.data.l[2];
3196  tlw->newCounterValueHi = event->xclient.data.l[3];
3197  }
3198  }
3199 #endif
3200  }
3201  } else if (event->xclient.message_type == ATOM(_QT_SCROLL_DONE)) {
3203  } else if (event->xclient.message_type == ATOM(XdndPosition)) {
3204  X11->xdndHandlePosition(widget, event, passive_only);
3205  } else if (event->xclient.message_type == ATOM(XdndEnter)) {
3206  X11->xdndHandleEnter(widget, event, passive_only);
3207  } else if (event->xclient.message_type == ATOM(XdndStatus)) {
3208  X11->xdndHandleStatus(widget, event, passive_only);
3209  } else if (event->xclient.message_type == ATOM(XdndLeave)) {
3210  X11->xdndHandleLeave(widget, event, passive_only);
3211  } else if (event->xclient.message_type == ATOM(XdndDrop)) {
3212  X11->xdndHandleDrop(widget, event, passive_only);
3213  } else if (event->xclient.message_type == ATOM(XdndFinished)) {
3214  X11->xdndHandleFinished(widget, event, passive_only);
3215  } else {
3216  if (passive_only) return 0;
3217  // All other are interactions
3218  }
3219  } else {
3220  X11->motifdndHandle(widget, event, passive_only);
3221  }
3222 
3223  return 0;
3224 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointer< QWidget > widget
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
long ASN1_INTEGER_get ASN1_INTEGER * a
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
static QWidget * activeModalWidget()
Returns the active modal widget.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool translateScrollDoneEvent(const XEvent *)
unsigned long ulong
Definition: qglobal.h:997
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
if(void) toggleToolbarShown
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
static void enterWhatsThisMode()
This function switches the user interface into "What&#39;s This?" mode.
Definition: qwhatsthis.cpp:633
int screen() const
Returns the number of the screen currently in use.
bool translateCloseEvent(const MSG &msg)

◆ x11EventFilter()

bool QApplication::x11EventFilter ( XEvent event)
virtual
Warning
This virtual function is only implemented under X11.

If you create an application that inherits QApplication and reimplement this function, you get direct access to all X events that the are received from the X server. The events are passed in the event parameter.

Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.

It is only the directly addressed messages that are filtered. You must install an event filter directly on the event dispatcher, which is returned by QAbstractEventDispatcher::instance(), to handle system wide messages.

See also
x11ProcessEvent()

Definition at line 3927 of file qapplication_x11.cpp.

3928 {
3929  return false;
3930 }

◆ x11ProcessEvent()

int QApplication::x11ProcessEvent ( XEvent event)

This function does the core processing of individual X {event}s, normally by dispatching Qt events to the right destination.

It returns 1 if the event was consumed by special handling, 0 if the event was consumed by normal handling, and -1 if the event was for an unrecognized widget.

See also
x11EventFilter()

Definition at line 3226 of file qapplication_x11.cpp.

3227 {
3228  Q_D(QApplication);
3229  QScopedLoopLevelCounter loopLevelCounter(d->threadData);
3230 
3231 #ifdef ALIEN_DEBUG
3232  //qDebug() << "QApplication::x11ProcessEvent:" << event->type;
3233 #endif
3234  switch (event->type) {
3235  case ButtonPress:
3236  pressed_window = event->xbutton.window;
3237  X11->userTime = event->xbutton.time;
3238  // fallthrough intended
3239  case ButtonRelease:
3240  X11->time = event->xbutton.time;
3241  break;
3242  case MotionNotify:
3243  X11->time = event->xmotion.time;
3244  break;
3245  case XKeyPress:
3246  X11->userTime = event->xkey.time;
3247  // fallthrough intended
3248  case XKeyRelease:
3249  X11->time = event->xkey.time;
3250  break;
3251  case PropertyNotify:
3252  X11->time = event->xproperty.time;
3253  break;
3254  case EnterNotify:
3255  case LeaveNotify:
3256  X11->time = event->xcrossing.time;
3257  break;
3258  case SelectionClear:
3259  X11->time = event->xselectionclear.time;
3260  break;
3261  default:
3262  break;
3263  }
3264 #ifndef QT_NO_XFIXES
3265  if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) {
3266  XFixesSelectionNotifyEvent *req =
3267  reinterpret_cast<XFixesSelectionNotifyEvent *>(event);
3268  X11->time = req->selection_timestamp;
3269  if (req->selection == ATOM(_NET_WM_CM_S0))
3270  X11->compositingManagerRunning = req->owner;
3271  }
3272 #endif
3273 
3274  QETWidget *widget = (QETWidget*)QWidget::find((WId)event->xany.window);
3275 
3276  if (wPRmapper) { // just did a widget reparent?
3277  if (widget == 0) { // not in std widget mapper
3278  switch (event->type) { // only for mouse/key events
3279  case ButtonPress:
3280  case ButtonRelease:
3281  case MotionNotify:
3282  case XKeyPress:
3283  case XKeyRelease:
3284  widget = qPRFindWidget(event->xany.window);
3285  break;
3286  }
3287  }
3288  else if (widget->testAttribute(Qt::WA_WState_Reparented))
3289  qPRCleanup(widget); // remove from alt mapper
3290  }
3291 
3292  QETWidget *keywidget=0;
3293  bool grabbed=false;
3294  if (event->type==XKeyPress || event->type==XKeyRelease) {
3295  keywidget = (QETWidget*)QWidget::keyboardGrabber();
3296  if (keywidget) {
3297  grabbed = true;
3298  } else if (!keywidget) {
3299  if (d->inPopupMode()) // no focus widget, see if we have a popup
3303  else if (widget)
3304  keywidget = (QETWidget*)widget->window();
3305  }
3306  }
3307 
3308 #ifndef QT_NO_IM
3309  // Filtering input events by the input context. It has to be taken
3310  // place before any other key event consumers such as eventfilters
3311  // and accelerators because some input methods require quite
3312  // various key combination and sequences. It often conflicts with
3313  // accelerators and so on, so we must give the input context the
3314  // filtering opportunity first to ensure all input methods work
3315  // properly regardless of application design.
3316 
3317  if(keywidget && keywidget->isEnabled() && keywidget->testAttribute(Qt::WA_InputMethodEnabled)) {
3318  // block user interaction during session management
3319  if((event->type==XKeyPress || event->type==XKeyRelease) && qt_sm_blockUserInput)
3320  return true;
3321 
3322  // for XIM handling
3323  QInputContext *qic = keywidget->inputContext();
3324  if(qic && qic->x11FilterEvent(keywidget, event))
3325  return true;
3326 
3327  // filterEvent() accepts QEvent *event rather than preexpanded
3328  // key event attribute values. This is intended to pass other
3329  // QInputEvent in future. Other non IM-related events should
3330  // not be forwarded to input contexts to prevent weird event
3331  // handling.
3332  if ((event->type == XKeyPress || event->type == XKeyRelease)) {
3333  int code = -1;
3334  int count = 0;
3335  Qt::KeyboardModifiers modifiers;
3337  QString text;
3338  KeySym keySym;
3339 
3340  qt_keymapper_private()->translateKeyEventInternal(keywidget, event, keySym, count,
3341  text, modifiers, code, type, false);
3342 
3343  // both key press/release is required for some complex
3344  // input methods. don't eliminate anything.
3345  QKeyEventEx keyevent(type, code, modifiers, text, false, qMax(qMax(count, 1), text.length()),
3346  event->xkey.keycode, keySym, event->xkey.state);
3347  if(qic && qic->filterEvent(&keyevent))
3348  return true;
3349  }
3350  } else
3351 #endif // QT_NO_IM
3352  {
3353  if (XFilterEvent(event, XNone))
3354  return true;
3355  }
3356 
3357  if (qt_x11EventFilter(event)) // send through app filter
3358  return 1;
3359 
3360  if (event->type == MappingNotify) {
3361  // keyboard mapping changed
3362  XRefreshKeyboardMapping(&event->xmapping);
3363 
3365  return 0;
3366  }
3367 #ifndef QT_NO_XKB
3368  else if (X11->use_xkb && event->type == X11->xkb_eventbase) {
3369  XkbAnyEvent *xkbevent = (XkbAnyEvent *) event;
3370  switch (xkbevent->xkb_type) {
3371  case XkbStateNotify:
3372  {
3373  XkbStateNotifyEvent *xkbstateevent = (XkbStateNotifyEvent *) xkbevent;
3374  if ((xkbstateevent->changed & XkbGroupStateMask) != 0) {
3375  qt_keymapper_private()->xkb_currentGroup = xkbstateevent->group;
3377  }
3378  break;
3379  }
3380  default:
3381  break;
3382  }
3383  }
3384 #endif
3385 
3386  if (!widget) { // don't know this windows
3388  if (popup) {
3389 
3390  /*
3391  That is more than suboptimal. The real solution should
3392  do some keyevent and buttonevent translation, so that
3393  the popup still continues to work as the user expects.
3394  Unfortunately this translation is currently only
3395  possible with a known widget. I'll change that soon
3396  (Matthias).
3397  */
3398 
3399  // Danger - make sure we don't lock the server
3400  switch (event->type) {
3401  case ButtonPress:
3402  case ButtonRelease:
3403  case XKeyPress:
3404  case XKeyRelease:
3405  do {
3406  popup->close();
3407  } while ((popup = qApp->activePopupWidget()));
3408  return 1;
3409  }
3410  }
3411  return -1;
3412  }
3413 
3414  if (event->type == XKeyPress || event->type == XKeyRelease)
3415  widget = keywidget; // send XKeyEvents through keywidget->x11Event()
3416 
3417  if (app_do_modal) // modal event handling
3418  if (!qt_try_modal(widget, event)) {
3419  if (event->type == ClientMessage && !widget->x11Event(event))
3420  x11ClientMessage(widget, event, true);
3421  return 1;
3422  }
3423 
3424 
3425  if (widget->x11Event(event)) // send through widget filter
3426  return 1;
3427 #if !defined (QT_NO_TABLET)
3428  if (!qt_xdnd_dragging) {
3430  for (int i = 0; i < tablets->size(); ++i) {
3431  QTabletDeviceData &tab = tablets->operator [](i);
3432  if (event->type == tab.xinput_motion
3433  || event->type == tab.xinput_button_release
3434  || event->type == tab.xinput_button_press
3435  || event->type == tab.xinput_proximity_in
3436  || event->type == tab.xinput_proximity_out) {
3437  widget->translateXinputEvent(event, &tab);
3438  return 0;
3439  }
3440  }
3441  }
3442 #endif
3443 
3444 #ifndef QT_NO_XRANDR
3445  if (X11->use_xrandr && event->type == (X11->xrandr_eventbase + RRScreenChangeNotify)) {
3446  // update Xlib internals with the latest screen configuration
3447  X11->ptrXRRUpdateConfiguration(event);
3448 
3449  // update the size for desktop widget
3450  int scr = X11->ptrXRRRootToScreen(X11->display, event->xany.window);
3452  QWidget *w = desktop->screen(scr);
3453  QSize oldSize(w->size());
3454  w->data->crect.setWidth(DisplayWidth(X11->display, scr));
3455  w->data->crect.setHeight(DisplayHeight(X11->display, scr));
3456  QResizeEvent e(w->size(), oldSize);
3457  QApplication::sendEvent(w, &e);
3458  if (w != desktop)
3459  QApplication::sendEvent(desktop, &e);
3460  }
3461 #endif // QT_NO_XRANDR
3462 
3463 #ifndef QT_NO_XFIXES
3464  if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) {
3465  XFixesSelectionNotifyEvent *req = reinterpret_cast<XFixesSelectionNotifyEvent *>(event);
3466 
3467  // compress all XFixes events related to this selection
3468  // we don't want to handle old SelectionNotify events.
3469  qt_xfixes_selection_event_data xfixes_event;
3470  xfixes_event.selection = req->selection;
3471  for (XEvent ev;;) {
3472  if (!XCheckIfEvent(X11->display, &ev, &qt_xfixes_scanner, (XPointer)&xfixes_event))
3473  break;
3474  }
3475 
3476  if (req->selection == ATOM(CLIPBOARD)) {
3477  if (qt_xfixes_clipboard_changed(req->owner, req->selection_timestamp)) {
3479  emit clipboard()->dataChanged();
3480  }
3481  } else if (req->selection == XA_PRIMARY) {
3482  if (qt_xfixes_selection_changed(req->owner, req->selection_timestamp)) {
3485  }
3486  }
3487  }
3488 #endif // QT_NO_XFIXES
3489 
3490  switch (event->type) {
3491 
3492  case ButtonRelease: // mouse event
3493  if (!d->inPopupMode() && !QWidget::mouseGrabber() && pressed_window != widget->internalWinId()
3494  && (widget = (QETWidget*) QWidget::find((WId)pressed_window)) == 0)
3495  break;
3496  // fall through intended
3497  case ButtonPress:
3498  if (event->xbutton.root != RootWindow(X11->display, widget->x11Info().screen())
3499  && ! qt_xdnd_dragging) {
3500  while (activePopupWidget())
3501  activePopupWidget()->close();
3502  return 1;
3503  }
3504  if (event->type == ButtonPress)
3505  qt_net_update_user_time(widget->window(), X11->userTime);
3506  // fall through intended
3507  case MotionNotify:
3508 #if !defined(QT_NO_TABLET)
3509  if (!qt_tabletChokeMouse) {
3510 #endif
3512  QPoint pos(event->xbutton.x, event->xbutton.y);
3513  pos = widget->d_func()->mapFromWS(pos);
3514  QWidget *window = widget->window();
3515  pos = widget->mapTo(window, pos);
3516  if (QWidget *child = window->childAt(pos)) {
3517  widget = static_cast<QETWidget *>(child);
3518  pos = child->mapFrom(window, pos);
3519  event->xbutton.x = pos.x();
3520  event->xbutton.y = pos.y();
3521  }
3522  }
3523  widget->translateMouseEvent(event);
3524 #if !defined(QT_NO_TABLET)
3525  } else {
3526  qt_tabletChokeMouse = false;
3527  }
3528 #endif
3529  break;
3530 
3531  case XKeyPress: // keyboard event
3532  qt_net_update_user_time(widget->window(), X11->userTime);
3533  // fallthrough intended
3534  case XKeyRelease:
3535  {
3536  if (keywidget && keywidget->isEnabled()) { // should always exist
3537  // qDebug("sending key event");
3538  qt_keymapper_private()->translateKeyEvent(keywidget, event, grabbed);
3539  }
3540  break;
3541  }
3542 
3543  case GraphicsExpose:
3544  case Expose: // paint event
3545  widget->translatePaintEvent(event);
3546  break;
3547 
3548  case ConfigureNotify: // window move/resize event
3549  if (event->xconfigure.event == event->xconfigure.window)
3550  widget->translateConfigEvent(event);
3551  break;
3552 
3553  case XFocusIn: { // got focus
3554  if ((widget->windowType() == Qt::Desktop))
3555  break;
3556  if (d->inPopupMode()) // some delayed focus event to ignore
3557  break;
3558  if (!widget->isWindow())
3559  break;
3560  if (event->xfocus.detail != NotifyAncestor &&
3561  event->xfocus.detail != NotifyInferior &&
3562  event->xfocus.detail != NotifyNonlinear)
3563  break;
3564  setActiveWindow(widget);
3565  if (X11->focus_model == QX11Data::FM_PointerRoot) {
3566  // We got real input focus from somewhere, but we were in PointerRoot
3567  // mode, so we don't trust this event. Check the focus model to make
3568  // sure we know what focus mode we are using...
3570  }
3571  }
3572  break;
3573 
3574  case XFocusOut: // lost focus
3575  if ((widget->windowType() == Qt::Desktop))
3576  break;
3577  if (!widget->isWindow())
3578  break;
3579  if (event->xfocus.mode == NotifyGrab) {
3581  break;
3582  }
3583  if (event->xfocus.detail != NotifyAncestor &&
3584  event->xfocus.detail != NotifyNonlinearVirtual &&
3585  event->xfocus.detail != NotifyNonlinear)
3586  break;
3587  if (!d->inPopupMode() && widget == QApplicationPrivate::active_window) {
3588  XEvent ev;
3589  bool focus_will_change = false;
3590  if (XCheckTypedEvent(X11->display, XFocusIn, &ev)) {
3591  // we're about to get an XFocusIn, if we know we will
3592  // get a new active window, we don't want to set the
3593  // active window to 0 now
3594  QWidget *w2 = QWidget::find(ev.xany.window);
3595  if (w2
3596  && w2->windowType() != Qt::Desktop
3597  && !d->inPopupMode() // some delayed focus event to ignore
3598  && w2->isWindow()
3599  && (ev.xfocus.detail == NotifyAncestor
3600  || ev.xfocus.detail == NotifyInferior
3601  || ev.xfocus.detail == NotifyNonlinear))
3602  focus_will_change = true;
3603 
3604  XPutBackEvent(X11->display, &ev);
3605  }
3606  if (!focus_will_change)
3607  setActiveWindow(0);
3608  }
3609  break;
3610 
3611  case EnterNotify: { // enter window
3612  if (QWidget::mouseGrabber() && (!d->inPopupMode() || widget->window() != activePopupWidget()))
3613  break;
3614  if ((event->xcrossing.mode != NotifyNormal
3615  && event->xcrossing.mode != NotifyUngrab)
3616  || event->xcrossing.detail == NotifyVirtual
3617  || event->xcrossing.detail == NotifyNonlinearVirtual)
3618  break;
3619  if (event->xcrossing.focus &&
3620  !(widget->windowType() == Qt::Desktop) && !widget->isActiveWindow()) {
3621  if (X11->focus_model == QX11Data::FM_Unknown) // check focus model
3623  if (X11->focus_model == QX11Data::FM_PointerRoot) // PointerRoot mode
3624  setActiveWindow(widget);
3625  }
3626 
3627  if (qt_button_down && !d->inPopupMode())
3628  break;
3629 
3630  QWidget *alien = widget->childAt(widget->d_func()->mapFromWS(QPoint(event->xcrossing.x,
3631  event->xcrossing.y)));
3632  QWidget *enter = alien ? alien : widget;
3633  QWidget *leave = 0;
3635  leave = qt_last_mouse_receiver;
3636  else
3637  leave = QWidget::find(curWin);
3638 
3639  // ### Alien: enter/leave might be wrong here with overlapping siblings
3640  // if the enter widget is native and stacked under a non-native widget.
3642  curWin = widget->internalWinId();
3643  qt_last_mouse_receiver = enter;
3644  if (!d->inPopupMode() || widget->window() == activePopupWidget())
3645  widget->translateMouseEvent(event); //we don't get MotionNotify, emulate it
3646  }
3647  break;
3648  case LeaveNotify: { // leave window
3649  QWidget *mouseGrabber = QWidget::mouseGrabber();
3650  if (mouseGrabber && !d->inPopupMode())
3651  break;
3652  if (curWin && widget->internalWinId() != curWin)
3653  break;
3654  if ((event->xcrossing.mode != NotifyNormal
3655  && event->xcrossing.mode != NotifyUngrab)
3656  || event->xcrossing.detail == NotifyInferior)
3657  break;
3658  if (!(widget->windowType() == Qt::Desktop))
3659  widget->translateMouseEvent(event); //we don't get MotionNotify, emulate it
3660 
3661  QWidget* enter = 0;
3662  QPoint enterPoint;
3663  XEvent ev;
3664  while (XCheckMaskEvent(X11->display, EnterWindowMask | LeaveWindowMask , &ev)
3665  && !qt_x11EventFilter(&ev)) {
3666  QWidget* event_widget = QWidget::find(ev.xcrossing.window);
3667  if(event_widget && event_widget->x11Event(&ev))
3668  break;
3669  if (ev.type == LeaveNotify
3670  || (ev.xcrossing.mode != NotifyNormal
3671  && ev.xcrossing.mode != NotifyUngrab)
3672  || ev.xcrossing.detail == NotifyVirtual
3673  || ev.xcrossing.detail == NotifyNonlinearVirtual)
3674  continue;
3675  enter = event_widget;
3676  if (enter)
3677  enterPoint = enter->d_func()->mapFromWS(QPoint(ev.xcrossing.x, ev.xcrossing.y));
3678  if (ev.xcrossing.focus &&
3679  enter && !(enter->windowType() == Qt::Desktop) && !enter->isActiveWindow()) {
3680  if (X11->focus_model == QX11Data::FM_Unknown) // check focus model
3682  if (X11->focus_model == QX11Data::FM_PointerRoot) // PointerRoot mode
3683  setActiveWindow(enter);
3684  }
3685  break;
3686  }
3687 
3688  if ((! enter || (enter->windowType() == Qt::Desktop)) &&
3689  event->xcrossing.focus && widget == QApplicationPrivate::active_window &&
3690  X11->focus_model == QX11Data::FM_PointerRoot // PointerRoot mode
3691  ) {
3692  setActiveWindow(0);
3693  }
3694 
3695  if (qt_button_down && !d->inPopupMode())
3696  break;
3697 
3698  if (!curWin)
3700 
3701  if (enter) {
3702  QWidget *alienEnter = enter->childAt(enterPoint);
3703  if (alienEnter)
3704  enter = alienEnter;
3705  }
3706 
3708  QWidget *activePopupWidget = qApp->activePopupWidget();
3709 
3710  if (mouseGrabber && activePopupWidget && leave == activePopupWidget)
3711  enter = mouseGrabber;
3712  else if (enter != widget && mouseGrabber) {
3713  if (!widget->rect().contains(widget->d_func()->mapFromWS(QPoint(event->xcrossing.x,
3714  event->xcrossing.y))))
3715  break;
3716  }
3717 
3719  qt_last_mouse_receiver = enter;
3720 
3721  if (enter && QApplicationPrivate::tryModalHelper(enter, 0)) {
3722  QWidget *nativeEnter = enter->internalWinId() ? enter : enter->nativeParentWidget();
3723  curWin = nativeEnter->internalWinId();
3724  static_cast<QETWidget *>(nativeEnter)->translateMouseEvent(&ev); //we don't get MotionNotify, emulate it
3725  } else {
3726  curWin = 0;
3728  }
3729  }
3730  break;
3731 
3732  case UnmapNotify: // window hidden
3733  if (widget->isWindow()) {
3735  widget->d_func()->topData()->waitingForMapNotify = 0;
3736 
3737  if (widget->windowType() != Qt::Popup && !widget->testAttribute(Qt::WA_DontShowOnScreen)) {
3738  widget->setAttribute(Qt::WA_Mapped, false);
3739  if (widget->isVisible()) {
3740  widget->d_func()->topData()->spont_unmapped = 1;
3741  QHideEvent e;
3743  widget->d_func()->hideChildren(true);
3744  }
3745  }
3746 
3747  if (!widget->d_func()->topData()->validWMState && X11->deferred_map.removeAll(widget))
3748  widget->doDeferredMap();
3749  }
3750  break;
3751 
3752  case MapNotify: // window shown
3753  if (widget->isWindow()) {
3754  // if we got a MapNotify when we were not waiting for it, it most
3755  // likely means the user has already asked to hide the window before
3756  // it ever being shown, so we try to withdraw a window after sending
3757  // the QShowEvent.
3758  bool pendingHide = widget->testAttribute(Qt::WA_WState_ExplicitShowHide) && widget->testAttribute(Qt::WA_WState_Hidden);
3759  widget->d_func()->topData()->waitingForMapNotify = 0;
3760 
3761  if (widget->windowType() != Qt::Popup) {
3762  widget->setAttribute(Qt::WA_Mapped);
3763  if (widget->d_func()->topData()->spont_unmapped) {
3764  widget->d_func()->topData()->spont_unmapped = 0;
3765  widget->d_func()->showChildren(true);
3766  QShowEvent e;
3768 
3769  // show() must have been called on this widget in
3770  // order to reach this point, but we could have
3771  // cleared these 2 attributes in case something
3772  // previously forced us into WithdrawnState
3773  // (e.g. kdocker)
3775  widget->setAttribute(Qt::WA_WState_Visible, true);
3776  }
3777  }
3778  if (pendingHide) // hide the window
3779  XWithdrawWindow(X11->display, widget->internalWinId(), widget->x11Info().screen());
3780  }
3781  break;
3782 
3783  case ClientMessage: // client message
3784  return x11ClientMessage(widget,event,False);
3785 
3786  case ReparentNotify: { // window manager reparents
3787  // compress old reparent events to self
3788  XEvent ev;
3789  while (XCheckTypedWindowEvent(X11->display,
3790  widget->effectiveWinId(),
3791  ReparentNotify,
3792  &ev)) {
3793  if (ev.xreparent.window != ev.xreparent.event) {
3794  XPutBackEvent(X11->display, &ev);
3795  break;
3796  }
3797  }
3798  if (widget->isWindow()) {
3799  QTLWExtra *topData = widget->d_func()->topData();
3800 
3801  // store the parent. Useful for many things, embedding for instance.
3802  topData->parentWinId = event->xreparent.parent;
3803 
3804  // the widget frame strut should also be invalidated
3805  widget->data->fstrut_dirty = 1;
3806 
3807  // work around broken window managers... if we get a
3808  // ReparentNotify before the MapNotify, we assume that
3809  // we're being managed by a reparenting window
3810  // manager.
3811  //
3812  // however, the WM_STATE property may not have been set
3813  // yet, but we are going to assume that it will
3814  // be... otherwise we could try to map again after getting
3815  // an UnmapNotify... which could then, in turn, trigger a
3816  // race in the window manager which causes the window to
3817  // disappear when it really should be hidden.
3818  if (topData->waitingForMapNotify && !topData->validWMState) {
3819  topData->waitingForMapNotify = 0;
3820  topData->validWMState = 1;
3821  }
3822 
3823  if (X11->focus_model != QX11Data::FM_Unknown) {
3824  // toplevel reparented...
3825  QWidget *newparent = QWidget::find(event->xreparent.parent);
3826  if (! newparent || (newparent->windowType() == Qt::Desktop)) {
3827  // we don't know about the new parent (or we've been
3828  // reparented to root), perhaps a window manager
3829  // has been (re)started? reset the focus model to unknown
3830  X11->focus_model = QX11Data::FM_Unknown;
3831  }
3832  }
3833  }
3834  break;
3835  }
3836  case SelectionRequest: {
3837  XSelectionRequestEvent *req = &event->xselectionrequest;
3838  if (! req)
3839  break;
3840 
3841  if (ATOM(XdndSelection) && req->selection == ATOM(XdndSelection)) {
3842  X11->xdndHandleSelectionRequest(req);
3843 
3844  } else if (qt_clipboard) {
3845  QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
3847  }
3848  break;
3849  }
3850  case SelectionClear: {
3851  XSelectionClearEvent *req = &event->xselectionclear;
3852  // don't deliver dnd events to the clipboard, it gets confused
3853  if (! req || (ATOM(XdndSelection) && req->selection == ATOM(XdndSelection)))
3854  break;
3855 
3856  if (qt_clipboard && !X11->use_xfixes) {
3857  QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
3859  }
3860  break;
3861  }
3862 
3863  case SelectionNotify: {
3864  XSelectionEvent *req = &event->xselection;
3865  // don't deliver dnd events to the clipboard, it gets confused
3866  if (! req || (ATOM(XdndSelection) && req->selection == ATOM(XdndSelection)))
3867  break;
3868 
3869  if (qt_clipboard) {
3870  QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
3872  }
3873  break;
3874  }
3875  case PropertyNotify:
3876  // some properties changed
3877  if (event->xproperty.window == QX11Info::appRootWindow(0)) {
3878  // root properties for the first screen
3879  if (!X11->use_xfixes && event->xproperty.atom == ATOM(_QT_CLIPBOARD_SENTINEL)) {
3882  emit clipboard()->dataChanged();
3883  }
3884  } else if (!X11->use_xfixes && event->xproperty.atom == ATOM(_QT_SELECTION_SENTINEL)) {
3888  }
3890  if (event->xproperty.atom == ATOM(RESOURCE_MANAGER))
3892  else if (event->xproperty.atom == ATOM(_QT_SETTINGS_TIMESTAMP))
3894  }
3895  }
3896  if (event->xproperty.window == QX11Info::appRootWindow()) {
3897  // root properties for the default screen
3898  if (event->xproperty.atom == ATOM(_QT_INPUT_ENCODING)) {
3900  } else if (event->xproperty.atom == ATOM(_NET_SUPPORTED)) {
3902  } else if (event->xproperty.atom == ATOM(_NET_VIRTUAL_ROOTS)) {
3904  } else if (event->xproperty.atom == ATOM(_NET_WORKAREA)) {
3906 
3907  // emit the workAreaResized() signal
3909  int numScreens = desktop->numScreens();
3910  for (int i = 0; i < numScreens; ++i)
3911  emit desktop->workAreaResized(i);
3912  }
3913  } else if (widget) {
3914  widget->translatePropertyEvent(event);
3915  } else {
3916  return -1; // don't know this window
3917  }
3918  break;
3919 
3920  default:
3921  break;
3922  }
3923 
3924  return 0;
3925 }
double d
Definition: qnumeric_p.h:62
Q_GUI_EXPORT bool qt_try_modal(QWidget *, XEvent *)
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
unsigned long WId
Definition: qwindowdefs.h:119
void doDeferredMap()
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
QPointer< QWidget > widget
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
void qPRCleanup(QWidget *widget)
bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
QRect crect
Definition: qwidget.h:131
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
bool isVisible() const
Definition: qwidget.h:1005
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
void workAreaResized(int)
static QWidget * active_window
bool isActiveWindow() const
static void qt_get_net_virtual_roots()
The QString class provides a Unicode character string.
Definition: qstring.h:83
QClipboard * qt_clipboard
bool qt_xdnd_dragging
Definition: qdnd_x11.cpp:237
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
static QETWidget * qPRFindWidget(Window oldwin)
#define Q_D(Class)
Definition: qglobal.h:2482
static Bool qt_xfixes_scanner(Display *, XEvent *event, XPointer arg)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool qt_sm_blockUserInput
static QWidget * focus_widget
QTabletDeviceDataList * qt_tablet_devices()
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
uint spont_unmapped
Definition: qwidget_p.h:194
QWidget * qt_button_down
NSWindow * window
static void qt_set_input_encoding()
bool translateXinputEvent(const XEvent *, QTabletDeviceData *tablet)
QWidgetPrivate * d_func()
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
void showChildren(bool spontaneous)
Definition: qwidget.cpp:8144
static void qt_check_focus_model()
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
bool qt_tabletChokeMouse
void changed(QClipboard::Mode mode)
This signal is emitted when the data for the given clipboard mode is changed.
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
#define emit
Definition: qobjectdefs.h:76
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
static QWidgetMapper * wPRmapper
virtual bool x11Event(XEvent *)
This special event handler can be reimplemented in a subclass to receive native X11 events passed in ...
Definition: qwidget.cpp:9969
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
QWidgetData * data
Definition: qwidget.h:815
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
bool qt_xfixes_clipboard_changed(Window clipboardOwner, Time timestamp)
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool translatePropertyEvent(const XEvent *)
void dataChanged()
This signal is emitted when the clipboard data is changed.
int numScreens() const
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
QTLWExtra * topData() const
Definition: qwidget_p.h:1004
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
static void setActiveWindow(QWidget *act)
Sets the active window to the active widget in response to a system event.
static Window curWin
QRect rect() const
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
void hideChildren(bool spontaneous)
Definition: qwidget.cpp:8167
bool isEnabled() const
Definition: qwidget.h:948
WId parentWinId
Definition: qwidget_p.h:198
QWidget * screen(int screen=-1)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
char * XPointer
Definition: qt_x11_p.h:180
void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp)
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
bool qt_check_selection_sentinel()
static void qt_set_x11_resources(const char *font=0, const char *fg=0, const char *bg=0, const char *button=0)
bool qt_check_clipboard_sentinel()
static bool obey_desktop_settings
static QWidget * activePopupWidget()
Returns the active popup widget.
QPointer< QWidget > qt_last_mouse_receiver
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static void changeKeyboard()
Definition: qkeymapper.cpp:90
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void selectionChanged()
This signal is emitted when the selection is changed.
void qt_desktopwidget_update_workarea()
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
static void qt_get_net_supported()
bool translatePaintEvent(const MSG &msg)
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
bool translateMouseEvent(const QWSMouseEvent *, int oldstate)
The QClipboardEvent class provides the parameters used in a clipboard event.
Definition: qevent.h:695
Q_GUI_EXPORT int qt_xfocusout_grab_counter
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
static bool app_do_modal
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
static bool qt_x11EventFilter(XEvent *ev)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
virtual bool x11FilterEvent(QWidget *keywidget, XEvent *event)
This function may be overridden only if input method is depending on X11 and you need raw XEvent...
virtual int x11ClientMessage(QWidget *, XEvent *, bool passive_only)
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
bool qt_xfixes_selection_changed(Window selectionOwner, Time timestamp)
QPoint mapFrom(QWidget *, const QPoint &) const
Translates the widget coordinate pos from the coordinate system of parent to this widget&#39;s coordinate...
Definition: qwidget.cpp:4433
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
uint validWMState
Definition: qwidget_p.h:196
bool translateConfigEvent(const MSG &msg)
uint waitingForMapNotify
Definition: qwidget_p.h:197
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented in a subclass to filter input events.
#define text
Definition: qobjectdefs.h:80
int screen() const
Returns the number of the screen currently in use.
static Window pressed_window
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Friends and Related Functions

◆ Q3AccelManager

friend class Q3AccelManager
friend

Definition at line 401 of file qapplication.h.

◆ QAction

friend class QAction
friend

Definition at line 409 of file qapplication.h.

◆ QDirectPainter

friend class QDirectPainter
friend

Definition at line 415 of file qapplication.h.

◆ QDirectPainterPrivate

Definition at line 416 of file qapplication.h.

◆ QETWidget

friend class QETWidget
friend

Definition at line 400 of file qapplication.h.

◆ QFontDatabasePrivate

friend class QFontDatabasePrivate
friend

Definition at line 410 of file qapplication.h.

◆ QGestureManager

friend class QGestureManager
friend

Definition at line 419 of file qapplication.h.

◆ QGraphicsItem

friend class QGraphicsItem
friend

Definition at line 395 of file qapplication.h.

◆ QGraphicsScene

friend class QGraphicsScene
friend

Definition at line 396 of file qapplication.h.

◆ QGraphicsScenePrivate

Definition at line 397 of file qapplication.h.

◆ QGraphicsWidget

friend class QGraphicsWidget
friend

Definition at line 394 of file qapplication.h.

◆ QInputContext

friend class QInputContext
friend

Definition at line 413 of file qapplication.h.

◆ QLineEdit

friend class QLineEdit
friend

Definition at line 406 of file qapplication.h.

◆ QShortcut

friend class QShortcut
friend

Definition at line 405 of file qapplication.h.

◆ QTextControl

friend class QTextControl
friend

Definition at line 407 of file qapplication.h.

◆ QTranslator

friend class QTranslator
friend

Definition at line 402 of file qapplication.h.

◆ QWidget

friend class QWidget
friend

Definition at line 398 of file qapplication.h.

◆ QWidgetAnimator

friend class QWidgetAnimator
friend

Definition at line 403 of file qapplication.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 399 of file qapplication.h.

◆ QWSDirectPainterSurface

Definition at line 414 of file qapplication.h.

Properties

◆ autoMaximizeThreshold

int QApplication::autoMaximizeThreshold
private

defines a threshold for auto maximizing widgets

Since
4.4

The auto maximize threshold is only available as part of Qt for Windows CE.

This property defines a threshold for the size of a window as a percentage of the screen size. If the minimum size hint of a window exceeds the threshold, calling show() will cause the window to be maximized automatically.

Setting the threshold to 100 or greater means that the widget will always be maximized. Alternatively, setting the threshold to 50 means that the widget will be maximized only if the vertical minimum size hint is at least 50% of the vertical screen size.

Setting the threshold to -1 disables the feature.

On Windows CE the default is -1 (i.e., it is disabled). On Windows Mobile the default is 40.

Definition at line 118 of file qapplication.h.

◆ autoSipEnabled

bool QApplication::autoSipEnabled
private

toggles automatic SIP (software input panel) visibility

Since
4.5

Set this property to true to automatically display the SIP when entering widgets that accept keyboard input. This property only affects widgets with the WA_InputMethodEnabled attribute set, and is typically used to launch a virtual keyboard on devices which have very few or no keys.

The property only has an effect on platforms which use software input panels, such as Windows CE and Symbian.

The default is platform dependent.

Definition at line 120 of file qapplication.h.

◆ cursorFlashTime

int QApplication::cursorFlashTime
private

the text cursor's flash (blink) time in milliseconds

The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time, but this may vary.

The default value on X11 is 1000 milliseconds. On Windows, the Control Panel value is used and setting this property sets the cursor flash time for all applications.

We recommend that widgets do not cache this value as it may change at any time if the user changes the global desktop settings.

Definition at line 104 of file qapplication.h.

◆ doubleClickInterval

int QApplication::doubleClickInterval
private

the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks

The default value on X11 is 400 milliseconds. On Windows and Mac OS, the operating system's value is used. However, on Windows and Symbian OS, calling this function sets the double click interval for all applications.

Definition at line 105 of file qapplication.h.

◆ globalStrut

QSize QApplication::globalStrut
private

the minimum size that any GUI element that the user can interact with should have

For example, no button should be resized to be smaller than the global strut size. The strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar I/O devices.

Example:

QSize MyWidget::sizeHint() const
{
}

By default, this property contains a QSize object with zero width and height.

Definition at line 110 of file qapplication.h.

◆ keyboardInputInterval

int QApplication::keyboardInputInterval
private

the time limit in milliseconds that distinguishes a key press from two consecutive key presses

Since
4.2

The default value on X11 is 400 milliseconds. On Windows and Mac OS, the operating system's value is used.

Definition at line 106 of file qapplication.h.

◆ layoutDirection

Qt::LayoutDirection QApplication::layoutDirection
private

the default layout direction for this application

On system start-up, the default layout direction depends on the application's language.

See also
QWidget::layoutDirection, isLeftToRight(), isRightToLeft()

Definition at line 102 of file qapplication.h.

◆ quitOnLastWindowClosed

bool QApplication::quitOnLastWindowClosed
private

whether the application implicitly quits when the last window is closed.

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except for sub-windows. Refer to Qt::WindowType for a detailed list of Qt::Window objects.

See also
quit(), QWidget::close()

Definition at line 113 of file qapplication.h.

◆ startDragDistance

int QApplication::startDragDistance
private

If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.

For example, if the mouse position of the click is stored in startPos and the current position (e.g. in the mouse move event) is currentPos, you can find out if a drag should be started with code like this:

if ((startPos - currentPos).manhattanLength() >=
startTheDrag();

Qt uses this value internally, e.g. in QFileDialog.

The default value is 4 pixels.

See also
startDragTime() QPoint::manhattanLength() {Drag and Drop}

Definition at line 112 of file qapplication.h.

◆ startDragTime

int QApplication::startDragTime
private

the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin

If you support drag and drop in your application, and want to start a drag and drop operation after the user has held down a mouse button for a certain amount of time, you should use this property's value as the delay.

Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for starting a drag.

The default value is 500 ms.

See also
startDragDistance(), {Drag and Drop}

Definition at line 111 of file qapplication.h.

◆ styleSheet

QString QApplication::styleSheet
private

the application style sheet

Since
4.2

By default, this property returns an empty string unless the user specifies the -stylesheet option on the command line when running the application.

See also
QWidget::setStyle(), {Qt Style Sheets}

Definition at line 115 of file qapplication.h.

◆ wheelScrollLines

int QApplication::wheelScrollLines
private

the number of lines to scroll a widget, when the mouse wheel is rotated.

If the value exceeds the widget's number of visible lines, the widget should interpret the scroll operation as a single page up or page down. If the widget is an item view class, then the result of scrolling one line depends on the setting of the widget's scroll mode. Scroll one line can mean scroll one item or scroll one pixel.

By default, this property has a value of 3.

Definition at line 108 of file qapplication.h.

◆ windowIcon

QIcon QApplication::windowIcon
private

the default window icon

See also
QWidget::setWindowIcon(), {Setting the Application Icon}

Definition at line 103 of file qapplication.h.


The documentation for this class was generated from the following files: