Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties | Friends | Related Functions

QApplication Class Reference

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

Inheritance diagram for QApplication:
Inheritance graph
Collaboration diagram for QApplication:
Collaboration graph

List of all members.

Public Types

enum  ColorSpec { NormalColor = 0, CustomColor = 1, ManyColor = 2 }
enum  Encoding { CodecForTr, UnicodeUTF8, DefaultCodec = CodecForTr }
typedef bool(* EventFilter )(void *message, long *result)
enum  Type { Tty, GuiClient, GuiServer }

Public Slots

static void aboutQt ()
static void closeAllWindows ()
void deleteLater ()
static void quit ()
void setStyleSheet (const QString &sheet)


void aboutToQuit ()
void commitDataRequest (QSessionManager &sessionManager)
void destroyed (QObject *=0)
void focusChanged (QWidget *old, QWidget *now)
void fontDatabaseChanged ()
void lastWindowClosed ()
void saveStateRequest (QSessionManager &sessionManager)
void unixSignal (int)

Public Member Functions

bool blockSignals (bool b)
const QObjectListchildren () const
virtual void commitData (QSessionManager &sm)
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 ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
virtual bool eventFilter (QObject *, QEvent *)
bool filterEvent (void *message, long *result)
template<typename T >
findChild (const QString &aName=QString()) const
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
template<typename T >
QList< T > findChildren (const QRegExp &re) const
bool inherits (const char *classname) const
QInputContextinputContext () const
void installEventFilter (QObject *)
bool isSessionRestored () const
bool isWidgetType () const
void killTimer (int id)
void moveToThread (QThread *thread)
bool notify (QObject *, QEvent *)
QString objectName () const
QObjectparent () const
QVariant property (const char *name) const
 QApplication (int &argc, char **argv, int=QT_VERSION)
 QApplication (int &argc, char **argv, bool GUIenabled, int=QT_VERSION)
 QApplication (int &argc, char **argv, Type, int=QT_VERSION)
void removeEventFilter (QObject *)
virtual void saveState (QSessionManager &sm)
QString sessionId () const
QString sessionKey () const
EventFilter setEventFilter (EventFilter filter)
void setInputContext (QInputContext *)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
int startTimer (int interval)
QString styleSheet () const
QThreadthread () const
QObjectUserDatauserData (uint id) const
virtual ~QApplication ()

Static Public Member Functions

static QWidgetactiveModalWidget ()
static QWidgetactivePopupWidget ()
static QWidgetactiveWindow ()
static void addLibraryPath (const QString &)
static void alert (QWidget *widget, int duration=0)
static QWidgetList allWidgets ()
static QString applicationDirPath ()
static QString applicationFilePath ()
static QString applicationName ()
static qint64 applicationPid ()
static QString applicationVersion ()
static QStringList arguments ()
static void beep ()
static void changeOverrideCursor (const QCursor &)
static QClipboardclipboard ()
static bool closingDown ()
static int colorSpec ()
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static int cursorFlashTime ()
static QDesktopWidgetdesktop ()
static bool desktopSettingsAware ()
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static int doubleClickInterval ()
static int exec ()
static void exit (int retcode=0)
static void flush ()
static QWidgetfocusWidget ()
static QFont font (const QWidget *)
static QFont font (const char *className)
static QFont font ()
static QFontMetrics fontMetrics ()
static QSize globalStrut ()
static bool hasPendingEvents ()
static void installTranslator (QTranslator *messageFile)
static QCoreApplicationinstance ()
static bool isEffectEnabled (Qt::UIEffect)
static bool isLeftToRight ()
static bool isRightToLeft ()
static Qt::LayoutDirection keyboardInputDirection ()
static int keyboardInputInterval ()
static QLocale keyboardInputLocale ()
static Qt::KeyboardModifiers keyboardModifiers ()
static Qt::LayoutDirection layoutDirection ()
static QStringList libraryPaths ()
static Qt::MouseButtons mouseButtons ()
static QString organizationDomain ()
static QString organizationName ()
static QCursoroverrideCursor ()
static QPalette palette (const QWidget *)
static QPalette palette ()
static QPalette palette (const char *className)
static void postEvent (QObject *receiver, QEvent *event)
static void postEvent (QObject *receiver, QEvent *event, int priority)
static void processEvents (QEventLoop::ProcessEventsFlags flags, int maxtime)
static void processEvents (QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
static bool quitOnLastWindowClosed ()
static uint registerUserData ()
static void removeLibraryPath (const QString &)
static void removePostedEvents (QObject *receiver)
static void removePostedEvents (QObject *receiver, int eventType)
static void removeTranslator (QTranslator *messageFile)
static void restoreOverrideCursor ()
static bool sendEvent (QObject *receiver, QEvent *event)
static void sendPostedEvents (QObject *receiver, int event_type)
static void sendPostedEvents ()
static void setActiveWindow (QWidget *act)
static void setApplicationName (const QString &application)
static void setApplicationVersion (const QString &version)
static void setAttribute (Qt::ApplicationAttribute attribute, bool on=true)
static void setColorSpec (int)
static void setCursorFlashTime (int)
static void setDesktopSettingsAware (bool)
static void setDoubleClickInterval (int)
static void setEffectEnabled (Qt::UIEffect, bool enable=true)
static void setFont (const QFont &, const char *className=0)
static void setGlobalStrut (const QSize &)
static void setGraphicsSystem (const QString &)
static void setKeyboardInputInterval (int)
static void setLayoutDirection (Qt::LayoutDirection direction)
static void setLibraryPaths (const QStringList &)
static void setOrganizationDomain (const QString &orgDomain)
static void setOrganizationName (const QString &orgName)
static void setOverrideCursor (const QCursor &)
static void setPalette (const QPalette &, const char *className=0)
static void setQuitOnLastWindowClosed (bool quit)
static void setStartDragDistance (int l)
static void setStartDragTime (int ms)
static void setStyle (QStyle *)
static QStylesetStyle (const QString &)
static void setWheelScrollLines (int)
static void setWindowIcon (const QIcon &icon)
static int startDragDistance ()
static int startDragTime ()
static bool startingUp ()
static QStylestyle ()
static void syncX ()
static bool testAttribute (Qt::ApplicationAttribute attribute)
static QWidgettopLevelAt (int x, int y)
static QWidgettopLevelAt (const QPoint &p)
static QWidgetList topLevelWidgets ()
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)
static Type type ()
static int wheelScrollLines ()
static QWidgetwidgetAt (const QPoint &p)
static QWidgetwidgetAt (int x, int y)
static QIcon windowIcon ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
bool compressEvent (QEvent *, QObject *receiver, QPostEventList *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
bool event (QEvent *)
int receivers (const char *signal) const
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes


Static Protected Attributes

static const QMetaObject staticQtMetaObject


QString applicationName
 the name of this application
QString applicationVersion
 the version of this application
int cursorFlashTime
 the text cursor's flash (blink) time in milliseconds
int doubleClickInterval
 the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
QSize globalStrut
 the minimum size that any GUI element that the user can interact with should have
int keyboardInputInterval
 the time limit in milliseconds that distinguishes a key press from two consecutive key presses
Qt::LayoutDirection layoutDirection
 the default layout direction for this application
QString objectName
 the name of this object
QString organizationDomain
 the Internet domain of the organization that wrote this application
QString organizationName
 the name of the organization that wrote this application
bool quitOnLastWindowClosed
 whether the application implicitly quits when the last window is closed.
int startDragDistance
int startDragTime
 the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin
QString styleSheet
 the application style sheet
int wheelScrollLines
 the number of lines to scroll a widget, when the mouse wheel is rotated.
QIcon windowIcon
 the default window icon


class Q3AccelManager
class QAction
class QCoreApplication
class QCoreApplicationPrivate
class QETWidget
class QFontDatabasePrivate
class QGraphicsScene
class QGraphicsScenePrivate
class QGraphicsWidget
class QLineEdit
struct QMetaObject
class QShortcut
class QTextControl
class QThreadData
class QTranslator
class QWidget
class QWidgetAnimator
class QWidgetPrivate

Related Functions

(Note that these are not member functions.)

void qAddPostRoutine (QtCleanUpFunction ptr)
qFindChild (const QObject *obj, const QString &name)
qFindChildqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
QList< T > qFindChildren (const QObject *obj, const QString &name)
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)()
QList< T > qFindChildrenqFindChildren (const QObject *obj, const QRegExp &regExp)()
T * qobject_cast (QObject *object)
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

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 and finalization, and provides session management. In addition, it handles most 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 {QApplication::QApplication()} {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} {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.

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

{2,1} 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 87 of file qapplication.h.

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

Generated by  Doxygen 1.6.0   Back to index