QApplication Class Reference

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

  1. #include <QApplication>

Inherits: QCoreApplication.

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:

  • It initializes the application with the user's desktop settings such as palette(), font() and doubleClickInterval(). It keeps track of these properties in case the user changes the desktop globally, for example through some kind of control panel.
  • It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. By using sendEvent() and postEvent() you can send your own events to widgets.
  • It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
  • It defines the application's look and feel, which is encapsulated in a QStyle object. This can be changed at runtime with setStyle().
  • It specifies how the application is to allocate colors. See setColorSpec() for details.
  • It provides localization of strings that are visible to the user via translate().
  • It provides some magical objects like the desktop() and the clipboard().
  • It knows about the application's windows. You can ask which widget is at a certain position using widgetAt(), get a list of topLevelWidgets() and closeAllWindows(), etc.
  • It manages the application's mouse cursor handling, see setOverrideCursor()
  • On the X window system, it provides functions to flush and sync the communication stream, see flushX() and syncX().
  • It provides support for sophisticated session management. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a shutdown process if termination isn't possible and even to preserve the entire application's state for a future session. See isSessionRestored(), sessionId() and commitData() and saveState() for details.

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, and QSettings.

Public Types

Toggle detailsenum QApplication::

ColorSpecColorSpec { NormalColor , CustomColor , ManyColor 2 ...} { NormalColor , CustomColor , ManyColor 2 }

ConstantValueDescription
QApplication::NormalColor 0 the default color allocation policy
QApplication::CustomColor 1 the same as NormalColor for X11; allocates colors to a palette on demand under Windows
QApplication::ManyColor 2 the right choice for applications that use thousands of colors

See setColorSpec() for full details.

Look up this member in the source code.

Toggle detailsenum QApplication::

TypeType { Tty , GuiClient , GuiServer 2 ...} { Tty , GuiClient , GuiServer 2 }

ConstantValueDescription
QApplication::Tty 0 a console application
QApplication::GuiClient 1 a GUI client application
QApplication::GuiServer 2 a GUI server application (for Qt for Embedded Linux)

Look up this member in the source code.

    Types

    Toggle detailstypedef QApplication QS60MainApplicationFactoryQS60MainApplicationFactory

    This is a typedef for a pointer to a function with the following signature:

    1. CApaApplication *myApplicationFactory();

    See also QApplication::QApplication().

    Look up this member in the source code.

    Toggle detailstypedef QApplication ColorModeColorModeQt3-support

    Use ColorSpec instead.

    Look up this member in the source code.

    Properties

    Qt3-supportQt3-support
    Toggle detailsautoMaximizeThresholdautoMaximizeThreshold : int

    This property holds defines a threshold for auto maximizing widgets

    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.

    Access functions:

    Look up this member in the source code.

    Toggle detailsautoSipEnabledautoSipEnabled : bool

    This property holds toggles automatic SIP (software input panel) visibility

    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.

    Access functions:

    Look up this member in the source code.

    Toggle detailscursorFlashTimecursorFlashTime : int

    This property holds 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.

    Access functions:

    Look up this member in the source code.

    Toggle detailsdoubleClickIntervaldoubleClickInterval : int

    This property holds 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.

    Access functions:

    Look up this member in the source code.

    Toggle detailsglobalStrutglobalStrut : QSize

    This property holds 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:

    1.                     QSize MyWidget::sizeHint() const
    2.  {
    3.     return QSize(80, 25).expandedTo(QApplication::globalStrut());
    4. }

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

    Access functions:

    Look up this member in the source code.

    Toggle detailskeyboardInputIntervalkeyboardInputInterval : int

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

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

    Access functions:

    Look up this member in the source code.

    Toggle detailslayoutDirectionlayoutDirection : Qt::LayoutDirection

    This property holds 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(), and isRightToLeft().

    Access functions:

    Look up this member in the source code.

    Toggle detailsquitOnLastWindowClosedquitOnLastWindowClosed : bool

    This property holds 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() and QWidget::close().

    Access functions:

    Look up this member in the source code.

    Toggle detailsstartDragDistancestartDragDistance : int

    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:

    1. if ((startPos - currentPos).manhattanLength() >=
    2.         QApplication::startDragDistance())
    3.     startTheDrag();

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

    The default value is 4 pixels.

    See also startDragTime(), QPoint::manhattanLength(), and Drag and Drop.

    Access functions:

    Look up this member in the source code.

    Toggle detailsstartDragTimestartDragTime : int

    This property holds 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() and Drag and Drop.

    Access functions:

    Look up this member in the source code.

    Toggle detailsstyleSheetstyleSheet : QString

    This property holds the application style sheet

    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() and Qt Style Sheets.

    Access functions:

    Look up this member in the source code.

    Toggle detailswheelScrollLineswheelScrollLines : int

    This property holds 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.

    Access functions:

    Look up this member in the source code.

    Toggle detailswindowIconwindowIcon : QIcon

    This property holds the default window icon

    See also QWidget::setWindowIcon() and Setting the Application Icon.

    Access functions:

    Look up this member in the source code.

    Toggle detailsCustomColorsCustomColors : const int

    Use CustomColor instead.

    Access functions:

      Look up this member in the source code.

      Toggle detailsNormalColorsNormalColors : const int

      Use NormalColor instead.

      Access functions:

        Look up this member in the source code.

        Public Functions

        Toggle details QApplication

        QApplicationQApplication ( int &argc , char **argv ) ( 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.
        • -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().

        Look up this member in the source code.

        Toggle details QApplication

        QApplicationQApplication ( int &argc , char **argv , bool GUIenabled ...) ( 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.

        1. int main(int argc, char **argv)
        2.  {
        3. #ifdef Q_WS_X11
        4.     bool useGUI = getenv("DISPLAY") != 0;
        5. #else
        6.     bool useGUI = true;
        7. #endif
        8.     QApplication app(argc, argv, useGUI);
        9.  
        10.     if (useGUI)  {
        11.        // start GUI version
        12.        ...
        13.     } else  {
        14.        // start non-GUI version
        15.        ...
        16.     }
        17.     return app.exec();
        18. }

        Look up this member in the source code.

        Toggle details QApplication

        QApplicationQApplication ( int &argc , char **argv , Type type ) ( 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).

        Look up this member in the source code.

        Toggle details QApplication

        QApplicationQApplication ( Display *display , Qt::HANDLE visual=0 , Qt::HANDLE colormap=0 ...) ( 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.

        Look up this member in the source code.

        Toggle details QApplication

        QApplicationQApplication ( Display *display , int &argc , char **argv , Qt::HANDLE visual=0 , Qt::HANDLE colormap=0 ...) ( 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.

        Look up this member in the source code.

        Toggle details QApplication

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

        Creates an application using the application factory given in factory, and using argc command line arguments in argv. factory can be leaving, but the error will be converted to a standard exception.

        This function is only available on S60.

        Look up this member in the source code.

        Toggle details QApplication

        ~QApplication~QApplication () () [virtual]

        Cleans up any window system resources that were allocated by this application. Sets the global variable qApp to 0.

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        activeModalWidgetactiveModalWidget () () [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() and topLevelWidgets().

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        activePopupWidgetactivePopupWidget () () [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() and topLevelWidgets().

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        activeWindowactiveWindow () () [static]

        Returns the application top-level window that has the keyboard input focus, or 0 if no application window has the focus. There might be an activeWindow() even if there is no focusWidget(), for example if no widget in that window accepts key events.

        See also setActiveWindow(), QWidget::setFocus(), QWidget::hasFocus(), and focusWidget().

        Look up this member in the source code.

        Toggle details void QApplication

        alertalert ( QWidget *widget , int msec=0 ) ( QWidget *widget , int msec=0 ) [static]

        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.

        Look up this member in the source code.

        Toggle details QWidgetList QApplication

        allWidgetsallWidgets () () [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:

        1. void updateAllWidgets()
        2.  {
        3.     foreach (QWidget *widget, QApplication::allWidgets())
        4.         widget->update();
        5. }

        See also topLevelWidgets() and QWidget::isVisible().

        Look up this member in the source code.

        Toggle details void QApplication

        beepbeep () () [static]

        Sounds the bell, using the default volume and sound. The function is not available in Qt for Embedded Linux.

        Look up this member in the source code.

        Toggle details void QApplication

        changeOverrideCursorchangeOverrideCursor ( const QCursor &cursor ) ( 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(), and QWidget::setCursor().

        Look up this member in the source code.

        Toggle details QClipboard * QApplication

        clipboardclipboard () () [static]

        Returns a pointer to the application global clipboard.

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

        Look up this member in the source code.

        Toggle details int QApplication

        colorSpeccolorSpec () () [static]

        Returns the color specification.

        See also QApplication::setColorSpec().

        Look up this member in the source code.

        Toggle details void QApplication

        commitDatacommitData ( QSessionManager &manager ) ( QSessionManager &manager ) [virtual]

        This function deals with 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(), and Session Management.

        Look up this member in the source code.

        Toggle details QDesktopWidget * QApplication

        desktopdesktop () () [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.

        Look up this member in the source code.

        Toggle details bool QApplication

        desktopSettingsAwaredesktopSettingsAware () () [static]

        Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false. The default is true.

        See also setDesktopSettingsAware().

        Look up this member in the source code.

        Toggle details bool QApplication

        eventevent ( QEvent *e ) ( QEvent *e ) [virtual protected]

        Reimplemented from QObject::event().

        Look up this member in the source code.

        Toggle details int QApplication

        execexec () () [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 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(), and QCoreApplication::exec().

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        focusWidgetfocusWidget () () [static]

        Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.

        See also QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), and focusChanged().

        Look up this member in the source code.

        Toggle details QFont QApplication

        fontfont () () [static]

        Returns the default application font.

        See also setFont(), fontMetrics(), and QWidget::font().

        Look up this member in the source code.

        Toggle details QFont QApplication

        fontfont ( const QWidget *widget ) ( const QWidget *widget ) [static]

        This is an overloaded function.

        Returns the default font for the widget.

        See also fontMetrics() and QWidget::setFont().

        Look up this member in the source code.

        Toggle details QFont QApplication

        fontfont ( const char *className ) ( const char *className ) [static]

        This is an overloaded function.

        Returns the font for widgets of the given className.

        See also setFont() and QWidget::font().

        Look up this member in the source code.

        Toggle details QFontMetrics QApplication

        fontMetricsfontMetrics () () [static]

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

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

        Look up this member in the source code.

        Toggle details QInputContext * QApplication

        inputContextinputContext () ()const

        Returns the QInputContext instance used by the application.

        See also setInputContext().

        Look up this member in the source code.

        Toggle details bool QApplication

        isEffectEnabledisEffectEnabled ( Qt::UIEffect effect ) ( 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() and Qt::UIEffect.

        Look up this member in the source code.

        Toggle details bool QApplication

        isLeftToRightisLeftToRight () () [static]

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

        See also layoutDirection() and isRightToLeft().

        Look up this member in the source code.

        Toggle details bool QApplication

        isRightToLeftisRightToLeft () () [static]

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

        See also layoutDirection() and isLeftToRight().

        Look up this member in the source code.

        Toggle details bool QApplication

        isSessionRestoredisSessionRestored () ()const

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

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

        Look up this member in the source code.

        Toggle details Qt::LayoutDirection QApplication

        keyboardInputDirectionkeyboardInputDirection () () [static]

        Returns the current keyboard input direction.

        Look up this member in the source code.

        Toggle details QLocale QApplication

        keyboardInputLocalekeyboardInputLocale () () [static]

        Returns the current keyboard input locale.

        Look up this member in the source code.

        Toggle details Qt::KeyboardModifiers QApplication

        keyboardModifierskeyboardModifiers () () [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().

        Look up this member in the source code.

        Toggle details bool QApplication

        keypadNavigationEnabledkeypadNavigationEnabled () () [static]

        Returns true if Qt is set to use keypad navigation; otherwise returns false. The default value is true on Symbian, but false on other platforms.

        This feature is available in Qt for Embedded Linux, Symbian and Windows CE only.

        Note: On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined.

        See also navigationMode().

        Look up this member in the source code.

        Toggle details bool QApplication

        macEventFiltermacEventFilter ( EventHandlerCallRefcaller , EventRefevent ...) ( EventHandlerCallRefcaller , EventRefevent ) [virtual]

        Warning: This virtual function is only implemented under Mac OS X when against Carbon.

        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.

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

        Cocoa uses a different event system which means this function is NOT CALLED when building Qt against Cocoa. If you want similar functionality subclass NSApplication and reimplement the sendEvent: message to handle all the NSEvents. You also will need to to instantiate your custom NSApplication before creating a QApplication. See Apple's NSApplication Reference for more information.

        Look up this member in the source code.

        Toggle details Qt::MouseButtons QApplication

        mouseButtonsmouseButtons () () [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().

        Look up this member in the source code.

        Toggle details Qt::NavigationMode QApplication

        navigationModenavigationMode () () [static]

        Returns what kind of focus navigation Qt is using.

        This feature is available in Qt for Embedded Linux, Symbian and Windows CE only.

        Note: On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined.

        Note: On Symbian, the default mode is Qt::NavigationModeNone for touch devices, and Qt::NavigationModeKeypadDirectional.

        See also setNavigationMode() and keypadNavigationEnabled().

        Look up this member in the source code.

        Toggle details bool QApplication

        notifynotify ( QObject *receiver , QEvent *e ) ( QObject *receiver , QEvent *e ) [virtual]

        Reimplemented from QCoreApplication::notify().

        Look up this member in the source code.

        Toggle details QCursor * QApplication

        overrideCursoroverrideCursor () () [static]

        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() and restoreOverrideCursor().

        Look up this member in the source code.

        Toggle details QPalette QApplication

        palettepalette () () [static]

        Returns the application palette.

        See also setPalette() and QWidget::palette().

        Look up this member in the source code.

        Toggle details QPalette QApplication

        palettepalette ( const QWidget *widget ) ( const QWidget *widget ) [static]

        This is an overloaded function.

        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() and QWidget::palette().

        Look up this member in the source code.

        Toggle details QPalette QApplication

        palettepalette ( const char *className ) ( const char *className ) [static]

        This is an overloaded function.

        Returns the palette for widgets of the given className.

        See also setPalette() and QWidget::palette().

        Look up this member in the source code.

        Toggle details QDecoration & QApplication

        qwsDecorationqwsDecoration () () [static]

        Return the QWSDecoration used for decorating windows.

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

        See also QDecoration.

        Look up this member in the source code.

        Toggle details bool QApplication

        qwsEventFilterqwsEventFilter ( QWSEvent *event ) ( 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.

        Look up this member in the source code.

        Toggle details void QApplication

        qwsSetCustomColorsqwsSetCustomColors ( QRgb *colorTable , int start , int numColors ...) ( 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.

        Look up this member in the source code.

        Toggle details void QApplication

        qwsSetDecorationqwsSetDecoration ( QDecoration *decoration ) ( QDecoration *decoration ) [static]

        Sets the QDecoration derived class to use for decorating the windows used by Qt for Embedded Linux to the decoration specified.

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

        See also QDecoration.

        Look up this member in the source code.

        Toggle details QDecoration * QApplication

        qwsSetDecorationqwsSetDecoration ( const QString &decoration ...) ( const QString &decoration ) [static]

        This is an overloaded function.

        Requests a QDecoration object for decoration from the QDecorationFactory.

        The string must be one of the QDecorationFactory::keys(). Keys are case insensitive.

        A later call to the QApplication constructor will override the requested style when a "-style" option is passed in as a commandline parameter.

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

        Look up this member in the source code.

        Toggle details void QApplication

        restoreOverrideCursorrestoreOverrideCursor () () [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() and overrideCursor().

        Look up this member in the source code.

        Toggle details void QApplication

        saveStatesaveState ( QSessionManager &manager ) ( QSessionManager &manager ) [virtual]

        This function deals with 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(), and Session Management.

        Look up this member in the source code.

        Toggle details QString QApplication

        sessionIdsessionId () ()const

        Returns the current 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(), and saveState().

        Look up this member in the source code.

        Toggle details QString QApplication

        sessionKeysessionKey () ()const

        Returns the session key in the current 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(), and saveState().

        Look up this member in the source code.

        Toggle details void QApplication

        setActiveWindowsetActiveWindow ( QWidget *active ) ( 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() and QWidget::activateWindow().

        Look up this member in the source code.

        Toggle details void QApplication

        setColorSpecsetColorSpec ( int spec ) ( 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:

        1. int main(int argc, char *argv[])
        2.  {
        3.     QApplication::setColorSpec(QApplication::ManyColor);
        4.     QApplication app(argc, argv);
        5.     ...
        6.     return app.exec();
        7. }

        See also colorSpec().

        Look up this member in the source code.

        Toggle details void QApplication

        setDesktopSettingsAwaresetDesktopSettingsAware ( bool on ) ( 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:

        1. int main(int argc, char *argv[])
        2.  {
        3.     QApplication::setDesktopSettingsAware(false);
        4.     QApplication app(argc, argv);
        5.     ...
        6.     return app.exec();
        7. }

        See also desktopSettingsAware().

        Look up this member in the source code.

        Toggle details void QApplication

        setEffectEnabledsetEffectEnabled ( Qt::UIEffect effect , bool enable=true ...) ( 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, and setDesktopSettingsAware().

        Look up this member in the source code.

        Toggle details void QApplication

        setFontsetFont ( const QFont &font , const char *className=0 ...) ( const QFont &font , const char *className=0 ) [static]

        Changes the default application font to font. 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(), and QWidget::setFont().

        Look up this member in the source code.

        Toggle details void QApplication

        setGraphicsSystemsetGraphicsSystem ( const QString &system ) ( const QString &system ) [static]

        Sets the default graphics backend to system, which will be used for on-screen widgets and QPixmaps. The available systems are "native", "raster" and "opengl".

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

        • the application commandline -graphicssystem switch
        • QApplication::setGraphicsSystem()
        • the QT_GRAPHICSSYSTEM environment variable
        • the Qt configure -graphicssystem switch

        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.

        Look up this member in the source code.

        Toggle details void QApplication

        setInputContextsetInputContext ( QInputContext *inputContext ) ( QInputContext *inputContext )

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

        Qt takes ownership of the given inputContext.

        See also inputContext().

        Look up this member in the source code.

        Toggle details void QApplication

        setNavigationModesetNavigationMode ( Qt::NavigationMode mode ) ( Qt::NavigationMode mode ) [static]

        Sets the kind of focus navigation Qt should use to mode.

        This feature is available in Qt for Embedded Linux, Symbian and Windows CE only.

        Note: On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined.

        Note: On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a virtual mouse cursor on non touchscreen devices, which is controlled by the cursor keys if there is no analog pointer device. On other platforms and on touchscreen devices, it has the same meaning as Qt::NavigationModeNone.

        See also navigationMode() and keypadNavigationEnabled().

        Look up this member in the source code.

        Toggle details void QApplication

        setOverrideCursorsetOverrideCursor ( const QCursor &cursor ) ( const QCursor &cursor ) [static]

        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:

        1.                     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
        2. calculateHugeMandelbrot();              // lunch time...
        3. QApplication::restoreOverrideCursor();

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

        Look up this member in the source code.

        Toggle details void QApplication

        setPalettesetPalette ( const QPalette &palette , const char *className=0 ...) ( const QPalette &palette , const char *className=0 ) [static]

        Changes the default application palette to palette.

        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(), and QStyle::polish().

        Look up this member in the source code.

        Toggle details void QApplication

        setStylesetStyle ( QStyle *style ) ( 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:

        1.                     QApplication::setStyle(new QWindowsStyle);

        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 se, 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(), and desktopSettingsAware().

        Look up this member in the source code.

        Toggle details QStyle * QApplication

        setStylesetStyle ( const QString &style ) ( const QString &style ) [static]

        This is an overloaded function.

        Requests a QStyle object for style from the QStyleFactory.

        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.

        Look up this member in the source code.

        Toggle details QStyle * QApplication

        stylestyle () () [static]

        Returns the application's style object.

        See also setStyle() and QStyle.

        Look up this member in the source code.

        Toggle details bool QApplication

        symbianEventFiltersymbianEventFilter ( const QSymbianEvent *event ...) ( const QSymbianEvent *event ) [virtual]

        Warning: This virtual function is only available on Symbian.

        If you create an application that inherits QApplication and reimplement this function, you get direct access to events that the are received from Symbian. 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, and does nothing with event.

        Look up this member in the source code.

        Toggle details int QApplication

        symbianProcessEventsymbianProcessEvent ( const QSymbianEvent *event ...) ( const QSymbianEvent *event )

        Warning: This function is only available on Symbian.

        This function processes an individual Symbian event event. It returns 1 if the event was handled, 0 if the event was not handled, and -1 if the event was not handled because the event is not known to Qt.

        Look up this member in the source code.

        Toggle details void QApplication

        syncXsyncX () () [static]

        Synchronizes with the X server in the X11 implementation. This normally takes some time. Does nothing on other platforms.

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        topLevelAttopLevelAt ( const QPoint &point ) ( const QPoint &point ) [static]

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

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        topLevelAttopLevelAt ( int x , int y ) ( int x , int y ) [static]

        This is an overloaded function.

        Returns the top-level widget at the point (x, y); returns 0 if there is no such widget.

        Look up this member in the source code.

        Toggle details QWidgetList QApplication

        topLevelWidgetstopLevelWidgets () () [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:

        1. void showAllHiddenTopLevelWidgets()
        2.  {
        3.     foreach (QWidget *widget, QApplication::topLevelWidgets())  {
        4.         if (widget->isHidden())
        5.             widget->show();
        6.     }
        7. }

        See also allWidgets(), QWidget::isWindow(), and QWidget::isHidden().

        Look up this member in the source code.

        Toggle details Type QApplication

        typetype () () [static]

        Returns the type of application (Tty, GuiClient, or GuiServer). The type is set when constructing the QApplication object.

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        widgetAtwidgetAt ( const QPoint &point ) ( 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(), and QWidget::grabKeyboard().

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        widgetAtwidgetAt ( int x , int y ) ( int x , int y ) [static]

        This is an overloaded function.

        Returns the widget at global screen position (x, y), or 0 if there is no Qt widget there.

        Look up this member in the source code.

        Toggle details bool QApplication

        x11EventFilterx11EventFilter ( XEvent *event ) ( 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().

        Look up this member in the source code.

        Toggle details int QApplication

        x11ProcessEventx11ProcessEvent ( XEvent *event ) ( XEvent *event )

        This function does the core processing of individual X events, 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().

        Look up this member in the source code.

        Toggle details ColorMode QApplication

        colorModecolorMode () () [static] Qt3-support

        Use colorSpec() instead, and use ColorSpec as the enum type.

        See also setColorMode().

        Look up this member in the source code.

        Toggle details void QApplication

        flushXflushX () () [static] Qt3-support

        Use flush() instead.

        Look up this member in the source code.

        Toggle details bool QApplication

        hasGlobalMouseTrackinghasGlobalMouseTracking () () [static] Qt3-support

        This feature does not exist anymore. This function always returns true in Qt 4.

        Look up this member in the source code.

        Toggle details Qt::Alignment QApplication

        horizontalAlignmenthorizontalAlignment ( Qt::Alignment align ...) ( Qt::Alignment align ) [static] Qt3-support

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

        Look up this member in the source code.

        Toggle details Qt::MacintoshVersion QApplication

        macVersionmacVersion () () [static] Qt3-support

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        mainWidgetmainWidget () () [static] Qt3-support

        Returns the main application widget, or 0 if there is no main widget.

        See also setMainWidget().

        Look up this member in the source code.

        Toggle details bool QApplication

        reverseLayoutreverseLayout () () [static] Qt3-support

        Use layoutDirection() instead.

        See also setReverseLayout().

        Look up this member in the source code.

        Toggle details void QApplication

        setColorModesetColorMode ( ColorMode mode ) ( ColorMode mode ) [static] Qt3-support

        Use setColorSpec() instead, and pass a ColorSpec value instead.

        See also colorMode().

        Look up this member in the source code.

        Toggle details void QApplication

        setFontsetFont ( const QFont &font , bool b , const char *className=0 ...) ( const QFont &font , bool b , const char *className=0 ) [static] Qt3-support

        Use the two-argument overload instead.

        Look up this member in the source code.

        Toggle details void QApplication

        setGlobalMouseTrackingsetGlobalMouseTracking ( bool dummy ) ( bool dummy ) [static] Qt3-support

        This function does nothing in Qt 4. The dummy parameter is ignored.

        See also hasGlobalMouseTracking().

        Look up this member in the source code.

        Toggle details void QApplication

        setMainWidgetsetMainWidget ( QWidget *mainWidget ) ( QWidget *mainWidget ) [static] Qt3-support

        Sets the application's main widget to mainWidget.

        In most respects the main widget is like any other widget, except that if it is closed, the application exits. QApplication does not take ownership of the mainWidget, so if you create your main widget on the heap you must delete it yourself.

        You need not have a main widget; connecting lastWindowClosed() to quit() is an alternative.

        On X11, this function also resizes and moves the main widget according to the -geometry command-line option, so you should set the default geometry (using QWidget::setGeometry()) before calling setMainWidget().

        See also mainWidget(), exec(), and quit().

        Look up this member in the source code.

        Toggle details void QApplication

        setOverrideCursorsetOverrideCursor ( const QCursor &cursor , bool replace ...) ( const QCursor &cursor , bool replace ) [static] Qt3-support

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

        Look up this member in the source code.

        Toggle details void QApplication

        setPalettesetPalette ( const QPalette &pal , bool b , const char *className=0 ...) ( const QPalette &pal , bool b , const char *className=0 ) [static] Qt3-support

        Use the two-argument overload instead.

        Look up this member in the source code.

        Toggle details void QApplication

        setReverseLayoutsetReverseLayout ( bool reverse ) ( bool reverse ) [static] Qt3-support

        Use setLayoutDirection() instead.

        See also reverseLayout().

        Look up this member in the source code.

        Toggle details void QApplication

        setWinStyleHighlightColorsetWinStyleHighlightColor ( const QColor &c ) ( const QColor &c ) [static] Qt3-support

        Use the palette instead.

        For example, if you have code like

        1. app.setWinStyleHighlightColor(color);

        you can rewrite it as

        1.                     QPalette palette(QApplication::palette());
        2. palette.setColor(QPalette::Highlight, color);
        3. QApplication::setPalette(palette);

        See also winStyleHighlightColor().

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        widgetAtwidgetAt ( int x , int y , bool child ) ( int x , int y , bool child ) [static] Qt3-support

        Use the two-argument widgetAt() overload to get the child widget. To get the top-level widget do this:

        1.                     QWidget *widget = qApp->widgetAt(x, y);
        2. if (widget)
        3.     widget = widget->window();

        Look up this member in the source code.

        Toggle details QWidget * QApplication

        widgetAtwidgetAt ( const QPoint &point , bool child ...) ( const QPoint &point , bool child ) [static] Qt3-support

        Use the single-argument widgetAt() overload to get the child widget. To get the top-level widget do this:

        1.                     QWidget *widget = qApp->widgetAt(point);
        2. if (widget)
        3.     widget = widget->window();

        Look up this member in the source code.

        Toggle details const QColor & QApplication

        winStyleHighlightColorwinStyleHighlightColor () () [static] Qt3-support

        Look up this member in the source code.

        Toggle details Qt::WindowsVersion QApplication

        winVersionwinVersion () () [static] Qt3-support

        Look up this member in the source code.

        Signals

        Toggle details void QApplication

        commitDataRequestcommitDataRequest ( QSessionManager &manager ) ( QSessionManager &manager ) [signal]

        This signal deals with session management. 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(), and Session Management.

        Look up this member in the source code.

        Toggle details void QApplication

        focusChangedfocusChanged ( QWidget *old , QWidget *now ) ( QWidget *old , QWidget *now ) [signal]

        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(), and Qt::FocusReason.

        Look up this member in the source code.

        Toggle details void QApplication

        fontDatabaseChangedfontDatabaseChanged () () [signal]

        Look up this member in the source code.

        Toggle details void QApplication

        lastWindowClosedlastWindowClosed () () [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().

        Look up this member in the source code.

        Toggle details void QApplication

        saveStateRequestsaveStateRequest ( QSessionManager &manager ) ( QSessionManager &manager ) [signal]

        This signal deals with 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 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(), and Session Management.

        Look up this member in the source code.

        Public Slots

        Toggle details void QApplication

        aboutQtaboutQt () () [static] [slot]

        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().

        Look up this member in the source code.

        Toggle details void QApplication

        closeAllWindowscloseAllWindows () () [static] [slot]

        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:

        1.     exitAct = new QAction(tr("E&xit"), this);
        2.     exitAct->setShortcuts(QKeySequence::Quit);
        3.     exitAct->setStatusTip(tr("Exit the application"));
        4.     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(), and QWidget::isWindow().

        Look up this member in the source code.

        Macros

        Toggle detailsqAppqApp

        A global pointer referring to the unique application object. It is equivalent to the pointer returned by the QCoreApplication::instance() function except that, in GUI applications, it is a pointer to a QApplication instance.

        Only one application object can be created.

        See also QCoreApplication::instance().

          Notes provided by the Qt Community
          Informative
          • 5

          Votes: 1

          Coverage: Qt library 4.7, 4.8

          Picture of Volker Volker

          Ant Farmer
          35 notes

          Nokia Certified Qt Developer

          Subclassing QApplication

          If you want to subclass QApplication, always pass argc as a reference, never as a value. This is a requirement of QCoreQApplication. See the doc note for QCoreApplication for some details.

          [Revisions]