- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qapplication.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QAPPLICATION_H
    00043 #define QAPPLICATION_H
    00044
    00045 #include <QtCore/qcoreapplication.h>
    00046 #include <QtGui/qwindowdefs.h>
    00047 #include <QtCore/qpoint.h>
    00048 #include <QtCore/qsize.h>
    00049 #include <QtGui/qcursor.h>
    00050 #ifdef QT_INCLUDE_COMPAT
    00051 # include <QtGui/qdesktopwidget.h>
    00052 #endif
    00053 #ifdef QT3_SUPPORT
    00054 # include <QtGui/qwidget.h>
    00055 # include <QtGui/qpalette.h>
    00056 #endif
    00057 #ifdef Q_WS_QWS
    00058 # include <QtGui/qrgb.h>
    00059 # include <QtGui/qtransportauth_qws.h>
    00060 #endif
    00061
    00062 QT_BEGIN_HEADER
    00063
    00064 #if defined(Q_OS_SYMBIAN)
    00065 class CApaApplication;
    00066 #endif
    00067
    00068 QT_BEGIN_NAMESPACE
    00069
    00070 QT_MODULE(Gui)
    00071
    00072 class QSessionManager;
    00073 class QDesktopWidget;
    00074 class QStyle;
    00075 class QEventLoop;
    00076 class QIcon;
    00077 class QInputContext;
    00078 template <typename T> class QList;
    00079 class QLocale;
    00080 #if defined(Q_WS_QWS)
    00081 class QDecoration;
    00082 #endif
    00083 #if defined(Q_OS_SYMBIAN)
    00084 class QSymbianEvent;
    00085 #endif
    00086
    00087 class QApplication;
    00088 class QApplicationPrivate;
    00089 #if defined(qApp)
    00090 #undef qApp
    00091 #endif
    00092 #define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
    00093
    00094
    00095 class Q_GUI_EXPORT QApplication : public QCoreApplication
    00096 {
    00097     Q_OBJECT
    00098     Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
    00099     Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
    00100     Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
    00101     Q_PROPERTY(int doubleClickInterval  READ doubleClickInterval WRITE setDoubleClickInterval)
    00102     Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
    00103 #ifndef QT_NO_WHEELEVENT
    00104     Q_PROPERTY(int wheelScrollLines  READ wheelScrollLines WRITE setWheelScrollLines)
    00105 #endif
    00106     Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
    00107     Q_PROPERTY(int startDragTime  READ startDragTime WRITE setStartDragTime)
    00108     Q_PROPERTY(int startDragDistance  READ startDragDistance WRITE setStartDragDistance)
    00109     Q_PROPERTY(bool quitOnLastWindowClosed  READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
    00110 #ifndef QT_NO_STYLE_STYLESHEET
    00111     Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
    00112 #endif
    00113 #ifdef Q_WS_WINCE
    00114     Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
    00115 #endif
    00116     Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
    00117
    00118 public:
    00119     enum Type { Tty, GuiClient, GuiServer };
    00120
    00121 #ifdef Q_OS_SYMBIAN
    00122     typedef CApaApplication * (*QS60MainApplicationFactory)();
    00123 #endif
    00124
    00125 #ifndef qdoc
    00126     QApplication(int &argc, char **argv, int = QT_VERSION);
    00127     QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION);
    00128     QApplication(int &argc, char **argv, Type, int = QT_VERSION);
    00129 #if defined(Q_WS_X11)
    00130     QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION);
    00131     QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION);
    00132 #endif
    00133 #if defined(Q_OS_SYMBIAN)
    00134     QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION);
    00135 #endif
    00136 #endif
    00137     virtual ~QApplication();
    00138
    00139     static Type type();
    00140
    00141     static QStyle *style();
    00142     static void setStyle(QStyle*);
    00143     static QStyle *setStyle(const QString&);
    00144     enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
    00145     static int colorSpec();
    00146     static void setColorSpec(int);
    00147     static void setGraphicsSystem(const QString &);
    00148
    00149 #ifndef QT_NO_CURSOR
    00150     static QCursor *overrideCursor();
    00151     static void setOverrideCursor(const QCursor &);
    00152     static void changeOverrideCursor(const QCursor &);
    00153     static void restoreOverrideCursor();
    00154 #endif
    00155     static QPalette palette();
    00156     static QPalette palette(const QWidget *);
    00157     static QPalette palette(const char *className);
    00158     static void setPalette(const QPalette &, const char* className = 0);
    00159     static QFont font();
    00160     static QFont font(const QWidget*);
    00161     static QFont font(const char *className);
    00162     static void setFont(const QFont &, const char* className = 0);
    00163     static QFontMetrics fontMetrics();
    00164
    00165     static void setWindowIcon(const QIcon &icon);
    00166     static QIcon windowIcon();
    00167
    00168
    00169 #ifdef QT3_SUPPORT
    00170     static QT3_SUPPORT QWidget *mainWidget();
    00171     static QT3_SUPPORT void setMainWidget(QWidget *);
    00172 #endif
    00173
    00174     static QWidgetList allWidgets();
    00175     static QWidgetList topLevelWidgets();
    00176
    00177     static QDesktopWidget *desktop();
    00178
    00179     static QWidget *activePopupWidget();
    00180     static QWidget *activeModalWidget();
    00181 #ifndef QT_NO_CLIPBOARD
    00182     static QClipboard *clipboard();
    00183 #endif
    00184     static QWidget *focusWidget();
    00185
    00186     static QWidget *activeWindow();
    00187     static void setActiveWindow(QWidget* act);
    00188
    00189     static QWidget *widgetAt(const QPoint &p);
    00190     static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
    00191     static QWidget *topLevelAt(const QPoint &p);
    00192     static inline QWidget *topLevelAt(int x, int y)  { return topLevelAt(QPoint(x, y)); }
    00193
    00194     static void syncX();
    00195     static void beep();
    00196     static void alert(QWidget *widget, int duration = 0);
    00197
    00198     static Qt::KeyboardModifiers keyboardModifiers();
    00199     static Qt::MouseButtons mouseButtons();
    00200
    00201     static void setDesktopSettingsAware(bool);
    00202     static bool desktopSettingsAware();
    00203
    00204     static void setCursorFlashTime(int);
    00205     static int cursorFlashTime();
    00206
    00207     static void setDoubleClickInterval(int);
    00208     static int doubleClickInterval();
    00209
    00210     static void setKeyboardInputInterval(int);
    00211     static int keyboardInputInterval();
    00212
    00213 #ifndef QT_NO_WHEELEVENT
    00214     static void setWheelScrollLines(int);
    00215     static int wheelScrollLines();
    00216 #endif
    00217     static void setGlobalStrut(const QSize &);
    00218     static QSize globalStrut();
    00219
    00220     static void setStartDragTime(int ms);
    00221     static int startDragTime();
    00222     static void setStartDragDistance(int l);
    00223     static int startDragDistance();
    00224
    00225     static void setLayoutDirection(Qt::LayoutDirection direction);
    00226     static Qt::LayoutDirection layoutDirection();
    00227
    00228     static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
    00229     static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
    00230
    00231     static bool isEffectEnabled(Qt::UIEffect);
    00232     static void setEffectEnabled(Qt::UIEffect, bool enable = true);
    00233
    00234 #if defined(Q_WS_MAC)
    00235     virtual bool macEventFilter(EventHandlerCallRef, EventRef);
    00236 #endif
    00237 #if defined(Q_WS_X11)
    00238     virtual bool x11EventFilter(XEvent *);
    00239     virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only);
    00240     int x11ProcessEvent(XEvent*);
    00241 #endif
    00242 #if defined(Q_OS_SYMBIAN)
    00243     int symbianProcessEvent(const QSymbianEvent *event);
    00244     virtual bool symbianEventFilter(const QSymbianEvent *event);
    00245 #endif
    00246 #if defined(Q_WS_QWS)
    00247     virtual bool qwsEventFilter(QWSEvent *);
    00248     int qwsProcessEvent(QWSEvent*);
    00249     void qwsSetCustomColors(QRgb *colortable, int start, int numColors);
    00250 #ifndef QT_NO_QWS_MANAGER
    00251     static QDecoration &qwsDecoration();
    00252     static void qwsSetDecoration(QDecoration *);
    00253     static QDecoration *qwsSetDecoration(const QString &decoration);
    00254 #endif
    00255 #endif
    00256
    00257
    00258 #if defined(Q_WS_WIN)
    00259     void winFocus(QWidget *, bool);
    00260     static void winMouseButtonUp();
    00261 #endif
    00262 #ifndef QT_NO_SESSIONMANAGER
    00263     // session management
    00264     bool isSessionRestored() const;
    00265     QString sessionId() const;
    00266     QString sessionKey() const;
    00267     virtual void commitData(QSessionManager& sm);
    00268     virtual void saveState(QSessionManager& sm);
    00269 #endif
    00270
    00271 #ifndef QT_NO_IM
    00272     void setInputContext(QInputContext *);
    00273     QInputContext *inputContext() const;
    00274 #endif
    00275
    00276     static QLocale keyboardInputLocale();
    00277     static Qt::LayoutDirection keyboardInputDirection();
    00278
    00279     static int exec();
    00280     bool notify(QObject *, QEvent *);
    00281
    00282
    00283     static void setQuitOnLastWindowClosed(bool quit);
    00284     static bool quitOnLastWindowClosed();
    00285
    00286 #ifdef QT_KEYPAD_NAVIGATION
    00287     static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
    00288     static bool keypadNavigationEnabled();
    00289     static void setNavigationMode(Qt::NavigationMode mode);
    00290     static Qt::NavigationMode navigationMode();
    00291 #endif
    00292
    00293 Q_SIGNALS:
    00294     void lastWindowClosed();
    00295     void focusChanged(QWidget *old, QWidget *now);
    00296     void fontDatabaseChanged();
    00297 #ifndef QT_NO_SESSIONMANAGER
    00298     void commitDataRequest(QSessionManager &sessionManager);
    00299     void saveStateRequest(QSessionManager &sessionManager);
    00300 #endif
    00301
    00302 public:
    00303     QString styleSheet() const;
    00304 public Q_SLOTS:
    00305 #ifndef QT_NO_STYLE_STYLESHEET
    00306     void setStyleSheet(const QString& sheet);
    00307 #endif
    00308 #ifdef Q_WS_WINCE
    00309     void setAutoMaximizeThreshold(const int threshold);
    00310     int autoMaximizeThreshold() const;
    00311 #endif
    00312     void setAutoSipEnabled(const bool enabled);
    00313     bool autoSipEnabled() const;
    00314     static void closeAllWindows();
    00315     static void aboutQt();
    00316
    00317 protected:
    00318 #if defined(Q_WS_QWS)
    00319     void setArgs(int, char **);
    00320 #endif
    00321     bool event(QEvent *);
    00322     bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
    00323
    00324 #ifdef QT3_SUPPORT
    00325 public:
    00326     static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); }
    00327     static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; }
    00328     static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align);
    00329     typedef int ColorMode;
    00330     enum { NormalColors = NormalColor, CustomColors = CustomColor };
    00331     static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); }
    00332     static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); }
    00333 #if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
    00334     static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; }
    00335 #endif
    00336 #if defined(Q_OS_MAC)
    00337     static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; }
    00338 #endif
    00339 #  ifndef QT_NO_CURSOR
    00340     inline static  QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace)
    00341     { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); }
    00342 #  endif
    00343     inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;}
    00344     inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {}
    00345     inline static QT3_SUPPORT void flushX() { flush(); }
    00346     static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) {
    00347         QPalette p(palette());
    00348         p.setColor(QPalette::Highlight, c);
    00349         setPalette(p);
    00350     }
    00351     static inline QT3_SUPPORT const QColor &winStyleHighlightColor()
    00352         { return palette().color(QPalette::Active, QPalette::Highlight); }
    00353     static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0)
    00354         { setPalette(pal, className); }
    00355     static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0)
    00356         { setFont(font, className); }
    00357
    00358     static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child)
    00359         { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); }
    00360     static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child)
    00361         { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); }
    00362 #endif // QT3_SUPPORT
    00363
    00364 #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc)
    00365     QApplication(int &argc, char **argv);
    00366     QApplication(int &argc, char **argv, bool GUIenabled);
    00367     QApplication(int &argc, char **argv, Type);
    00368 #if defined(Q_WS_X11)
    00369     QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0);
    00370     QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
    00371 #endif
    00372 #if defined(Q_OS_SYMBIAN) || defined(qdoc)
    00373     QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv);
    00374 #endif
    00375 #endif
    00376
    00377 private:
    00378     Q_DISABLE_COPY(QApplication)
    00379     Q_DECLARE_PRIVATE(QApplication)
    00380
    00381     friend class QGraphicsWidget;
    00382     friend class QGraphicsItem;
    00383     friend class QGraphicsScene;
    00384     friend class QGraphicsScenePrivate;
    00385     friend class QWidget;
    00386     friend class QWidgetPrivate;
    00387     friend class QETWidget;
    00388     friend class Q3AccelManager;
    00389     friend class QTranslator;
    00390     friend class QWidgetAnimator;
    00391 #ifndef QT_NO_SHORTCUT
    00392     friend class QShortcut;
    00393     friend class QLineEdit;
    00394     friend class QTextControl;
    00395 #endif
    00396     friend class QAction;
    00397     friend class QFontDatabasePrivate;
    00398
    00399 #if defined(Q_WS_QWS)
    00400     friend class QInputContext;
    00401     friend class QWSDirectPainterSurface;
    00402     friend class QDirectPainter;
    00403     friend class QDirectPainterPrivate;
    00404 #endif
    00405 #ifndef QT_NO_GESTURES
    00406     friend class QGestureManager;
    00407 #endif
    00408
    00409 #if defined(Q_WS_MAC) || defined(Q_WS_X11)
    00410     Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut())
    00411 #endif
    00412 #if defined(QT_RX71_MULTITOUCH)
    00413     Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents())
    00414 #endif
    00415 #if defined(Q_OS_SYMBIAN)
    00416     Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit())
    00417 #endif
    00418 };
    00419
    00420 QT_END_NAMESPACE
    00421
    00422 QT_END_HEADER
    00423
    00424 #endif // QAPPLICATION_H