source: trunk/doc/html/qapplication-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 17.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qapplication.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qapplication.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qapplication.h</h1>
33
34<p>This is the verbatim text of the qapplication.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qapplication-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QApplication class
41**
42** Created : 931107
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QAPPLICATION_H
75#define QAPPLICATION_H
76
77#ifndef QT_H
78#include "qdesktopwidget.h"
79#include "qasciidict.h"
80#include "qpalette.h"
81#include "qtranslator.h"
82#include "qstrlist.h"
83#include "qstringlist.h"
84#endif // QT_H
85
86class QSessionManager;
87class QStyle;
88class QTranslator;
89class QEventLoop;
90#if defined(Q_WS_QWS)
91class QWSDecoration;
92#endif
93
94#ifdef QT_THREAD_SUPPORT
95class QMutex;
96#endif // QT_THREAD_SUPPORT
97
98
99class QApplication;
100extern Q_EXPORT QApplication *qApp; // global application object
101
102
103class Q_EXPORT QApplication : public QObject
104{
105 Q_OBJECT
106public:
107 QApplication( int &amp;argc, char **argv );
108 QApplication( int &amp;argc, char **argv, bool GUIenabled );
109 enum Type { Tty, GuiClient, GuiServer };
110 QApplication( int &amp;argc, char **argv, Type );
111#if defined(Q_WS_X11)
112 QApplication( Display* dpy, HANDLE visual = 0, HANDLE cmap = 0 );
113 QApplication( Display *dpy, int argc, char **argv,
114 HANDLE visual = 0, HANDLE cmap= 0 );
115#endif
116 virtual ~QApplication();
117
118 int argc() const;
119 char **argv() const;
120
121 Type type() const;
122
123#ifndef QT_NO_STYLE
124 static QStyle &amp;style();
125 static void setStyle( QStyle* );
126 static QStyle* setStyle( const QString&amp; );
127#endif
128#ifndef Q_QDOC
129 enum ColorMode { NormalColors, CustomColors };
130 static ColorMode colorMode();
131 static void setColorMode( QApplication::ColorMode );
132#endif
133
134 enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
135 static int colorSpec();
136 static void setColorSpec( int );
137#ifndef QT_NO_CURSOR
138 static QCursor *overrideCursor();
139 static void setOverrideCursor( const QCursor &amp;, bool replace=FALSE );
140 static void restoreOverrideCursor();
141#endif
142 static bool hasGlobalMouseTracking();
143 static void setGlobalMouseTracking( bool enable );
144#ifndef QT_NO_PALETTE
145 static QPalette palette( const QWidget* = 0 );
146 static void setPalette( const QPalette &amp;, bool informWidgets=FALSE,
147 const char* className = 0 );
148#endif
149 static QFont font( const QWidget* = 0 );
150 static void setFont( const QFont &amp;, bool informWidgets=FALSE,
151 const char* className = 0 );
152 static QFontMetrics fontMetrics();
153
154 QWidget *mainWidget() const;
155 virtual void setMainWidget( QWidget * );
156 virtual void polish( QWidget * );
157
158 static QWidgetList *allWidgets();
159 static QWidgetList *topLevelWidgets();
160
161 static QDesktopWidget *desktop();
162
163 static QWidget *activePopupWidget();
164 static QWidget *activeModalWidget();
165#ifndef QT_NO_CLIPBOARD
166 static QClipboard *clipboard();
167#endif
168 QWidget *focusWidget() const;
169 QWidget *activeWindow() const;
170
171 static QWidget *widgetAt( int x, int y, bool child=FALSE );
172 static QWidget *widgetAt( const QPoint &amp;, bool child=FALSE );
173
174 static QEventLoop *eventLoop();
175
176 int exec();
177 void processEvents();
178 void processEvents( int maxtime );
179 void processOneEvent();
180 bool hasPendingEvents();
181 int enter_loop();
182 void exit_loop();
183 int loopLevel() const;
184 static void exit( int retcode=0 );
185
186 static bool sendEvent( QObject *receiver, QEvent *event );
187 static void postEvent( QObject *receiver, QEvent *event );
188 static void sendPostedEvents( QObject *receiver, int event_type );
189 static void sendPostedEvents();
190
191 static void removePostedEvents( QObject *receiver );
192
193 virtual bool notify( QObject *, QEvent * );
194
195 static bool startingUp();
196 static bool closingDown();
197
198 static void flushX();
199 static void flush();
200 static void syncX();
201
202 static void beep();
203
204#ifndef QT_NO_TRANSLATION
205# ifndef QT_NO_TEXTCODEC
206 void setDefaultCodec( QTextCodec * );
207 QTextCodec* defaultCodec() const;
208# endif
209 void installTranslator( QTranslator * );
210 void removeTranslator( QTranslator * );
211#endif
212 enum Encoding { DefaultCodec, UnicodeUTF8 };
213 QString translate( const char * context,
214 const char * key,
215 const char * comment = 0,
216 Encoding encoding = DefaultCodec ) const;
217#ifndef QT_NO_DIR
218 QString applicationDirPath();
219 QString applicationFilePath();
220#endif
221#ifndef QT_NO_PALETTE
222 // obsolete functions
223 static void setWinStyleHighlightColor( const QColor &amp;c ) {
224 QPalette p( palette() );
225 p.setColor( QColorGroup::Highlight, c );
226 setPalette( p, TRUE);
227 }
228 static const QColor &amp;winStyleHighlightColor() {
229 return palette().active().highlight();
230 }
231#endif
232 static void setDesktopSettingsAware( bool );
233 static bool desktopSettingsAware();
234
235 static void setCursorFlashTime( int );
236 static int cursorFlashTime();
237
238 static void setDoubleClickInterval( int );
239 static int doubleClickInterval();
240#ifndef QT_NO_WHEELEVENT
241 static void setWheelScrollLines( int );
242 static int wheelScrollLines();
243#endif
244 static void setGlobalStrut( const QSize &amp; );
245 static QSize globalStrut();
246
247#ifndef QT_NO_COMPONENT
248 static void setLibraryPaths( const QStringList &amp; );
249 static QStringList libraryPaths();
250 static void addLibraryPath( const QString &amp; );
251 static void removeLibraryPath( const QString &amp; );
252#endif // QT_NO_COMPONENT
253 static void setStartDragTime( int ms );
254 static int startDragTime();
255 static void setStartDragDistance( int l );
256 static int startDragDistance();
257
258 static void setReverseLayout( bool b );
259 static bool reverseLayout();
260
261 static int horizontalAlignment( int align );
262
263 static bool isEffectEnabled( Qt::UIEffect );
264 static void setEffectEnabled( Qt::UIEffect, bool enable = TRUE );
265
266#if defined(Q_WS_MAC)
267 virtual bool macEventFilter( EventHandlerCallRef, EventRef );
268#endif
269#if defined(Q_WS_WIN)
270 virtual bool winEventFilter( MSG * );
271#endif
272#if defined(Q_WS_X11)
273 virtual bool x11EventFilter( XEvent * );
274 virtual int x11ClientMessage( QWidget*, XEvent*, bool passive_only);
275 int x11ProcessEvent( XEvent* );
276#endif
277#if defined(Q_WS_QWS)
278 virtual bool qwsEventFilter( QWSEvent * );
279 int qwsProcessEvent( QWSEvent* );
280 void qwsSetCustomColors( QRgb *colortable, int start, int numColors );
281/*!
282 \internal
283 Returns true if the process is GUI server
284*/
285 bool qwsIsGUIServer();
286#ifndef QT_NO_QWS_MANAGER
287 static QWSDecoration &amp;qwsDecoration();
288 static void qwsSetDecoration( QWSDecoration *);
289#endif
290#endif
291
292#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
293 static WindowsVersion winVersion();
294#elif defined(Q_OS_MAC)
295 static MacintoshVersion macVersion();
296#endif
297#if defined(Q_WS_WIN)
298 void winFocus( QWidget *, bool );
299 static void winMouseButtonUp();
300#endif
301
302#ifndef QT_NO_SESSIONMANAGER
303 // session management
304 bool isSessionRestored() const;
305 QString sessionId() const;
306 QString sessionKey() const;
307 virtual void commitData( QSessionManager&amp; sm );
308 virtual void saveState( QSessionManager&amp; sm );
309#endif
310#if defined(Q_WS_X11)
311 static void create_xim();
312 static void close_xim();
313 static bool x11_apply_settings();
314#endif
315 void wakeUpGuiThread();
316#if defined(QT_THREAD_SUPPORT)
317 void lock();
318 void unlock(bool wakeUpGui = TRUE);
319 bool locked();
320 bool tryLock();
321#endif
322
323signals:
324 void lastWindowClosed();
325 void aboutToQuit();
326 void guiThreadAwake();
327
328public slots:
329 void quit();
330 void closeAllWindows();
331 void aboutQt();
332
333#if defined(Q_WS_QWS)
334protected:
335 void setArgs(int, char **);
336#endif
337
338protected:
339 bool event(QEvent *);
340
341private:
342 void construct( int &amp;argc, char **argv, Type );
343 void initialize( int, char ** );
344 void init_precmdline();
345 void process_cmdline( int* argcptr, char ** argv );
346 bool internalNotify( QObject *, QEvent * );
347#if defined(Q_WS_QWS)
348 static QWidget *findChildWidget( const QWidget *p, const QPoint &amp;pos );
349 static QWidget *findWidget( const QObjectList&amp;, const QPoint &amp;, bool rec );
350#endif
351
352#if defined(Q_WS_MAC)
353 bool do_mouse_down(Point *, bool *);
354 static QMAC_PASCAL OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
355 static QMAC_PASCAL OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
356 static QMAC_PASCAL void qt_context_timer_callbk(EventLoopTimerRef, void *);
357 static QMAC_PASCAL void qt_select_timer_callbk(EventLoopTimerRef, void *);
358 static bool qt_mac_apply_settings();
359 friend class QMacInputMethod;
360 friend QMAC_PASCAL OSStatus qt_window_event(EventHandlerCallRef, EventRef, void *);
361 friend void qt_mac_update_os_settings();
362 friend bool qt_set_socket_handler( int, int, QObject *, bool);
363 friend void qt_mac_destroy_widget(QWidget *);
364 friend void qt_init(int *, char **, QApplication::Type);
365#endif
366
367#ifdef QT_THREAD_SUPPORT
368 static QMutex *qt_mutex;
369#endif // QT_THREAD_SUPPORT
370
371 int app_argc;
372 char **app_argv;
373 bool quit_now;
374 int quit_code;
375 static QStyle *app_style;
376 static int app_cspec;
377#ifndef QT_NO_PALETTE
378 static QPalette *app_pal;
379#endif
380 static QFont *app_font;
381#ifndef QT_NO_CURSOR
382 static QCursor *app_cursor;
383#endif
384 static QEventLoop* eventloop;
385 static int app_tracking;
386 static bool is_app_running;
387 static bool is_app_closing;
388 static bool app_exit_loop;
389 static int loop_level;
390 static QWidget *main_widget;
391 static QWidget *focus_widget;
392 static QWidget *active_window;
393 static bool obey_desktop_settings;
394 static int cursor_flash_time;
395 static int mouse_double_click_time;
396 static int wheel_scroll_lines;
397 static int composedUnicode; // Value, meta-composed character
398
399 static bool animate_ui;
400 static bool animate_menu;
401 static bool animate_tooltip;
402 static bool animate_combo;
403 static bool fade_menu;
404 static bool fade_tooltip;
405 static bool animate_toolbox;
406 static bool widgetCount; // Coupled with -widgetcount switch
407 static bool metaComposeUnicode;
408
409 QValueList&lt;QTranslator*&gt; *translators;
410#ifndef QT_NO_SESSIONMANAGER
411 QSessionManager *session_manager;
412 QString session_id;
413 static QString* session_key;
414 bool is_session_restored;
415#endif
416#if defined(Q_WS_X11) &amp;&amp; !defined (QT_NO_STYLE )
417 static void x11_initialize_style();
418#endif
419
420 static QSize app_strut;
421#ifndef QT_NO_COMPONENT
422 static QStringList *app_libpaths;
423#endif
424 static QAsciiDict&lt;QPalette&gt; *app_palettes;
425 static QAsciiDict&lt;QFont&gt; *app_fonts;
426
427 static QWidgetList *popupWidgets;
428 bool inPopupMode() const;
429 void closePopup( QWidget *popup );
430 void openPopup( QWidget *popup );
431 void setActiveWindow( QWidget* act );
432
433 static bool sendSpontaneousEvent( QObject *receiver, QEvent *event );
434 static void removePostedEvent( QEvent * );
435
436 friend class QWidget;
437 friend class QETWidget;
438 friend class QDialog;
439 friend class QAccelManager;
440 friend class QEvent;
441 friend class QTranslator;
442 friend class QEventLoop;
443 friend Q_EXPORT void qt_ucm_initialize( QApplication * );
444#if defined(Q_WS_WIN)
445 friend bool qt_sendSpontaneousEvent( QObject*, QEvent* );
446#endif
447#if defined(Q_WS_QWS)
448 friend class QInputContext;
449#endif
450private: // Disabled copy constructor and operator=
451#if defined(Q_DISABLE_COPY)
452 QApplication( const QApplication &amp; );
453 QApplication &amp;operator=( const QApplication &amp; );
454#endif
455};
456
457inline int QApplication::argc() const
458{
459 return app_argc;
460}
461
462inline char **QApplication::argv() const
463{
464 return app_argv;
465}
466
467#if defined(Q_WS_QWS)
468inline void QApplication::setArgs(int c, char **v)
469{
470 app_argc = c;
471 app_argv = v;
472}
473#endif
474
475#ifndef QT_NO_CURSOR
476inline QCursor *QApplication::overrideCursor()
477{
478 return app_cursor;
479}
480#endif
481inline bool QApplication::hasGlobalMouseTracking()
482{
483 return app_tracking &gt; 0;
484}
485
486inline QWidget *QApplication::mainWidget() const
487{
488 return main_widget;
489}
490
491inline QWidget *QApplication::focusWidget() const
492{
493 return focus_widget;
494}
495
496inline QWidget *QApplication::activeWindow() const
497{
498 return active_window;
499}
500
501inline QWidget *QApplication::widgetAt( const QPoint &amp;p, bool child )
502{
503 return widgetAt( p.x(), p.y(), child );
504}
505
506inline bool QApplication::inPopupMode() const
507{
508 return popupWidgets != 0;
509}
510#ifndef QT_NO_SESSIONMANAGER
511inline bool QApplication::isSessionRestored() const
512{
513 return is_session_restored;
514}
515
516inline QString QApplication::sessionId() const
517{
518 return session_id;
519}
520
521inline QString QApplication::sessionKey() const
522{
523 return session_key ? *session_key : QString::null;
524}
525#endif
526inline QSize QApplication::globalStrut()
527{
528 return app_strut;
529}
530
531inline bool QApplication::sendEvent( QObject *receiver, QEvent *event )
532{ if ( event ) event-&gt;spont = FALSE; return qApp ? qApp-&gt;notify( receiver, event ) : FALSE; }
533
534inline bool QApplication::sendSpontaneousEvent( QObject *receiver, QEvent *event )
535{ if ( event ) event-&gt;spont = TRUE; return qApp ? qApp-&gt;notify( receiver, event ) : FALSE; }
536
537#ifdef QT_NO_TRANSLATION
538// Simple versions
539inline QString QApplication::translate( const char *, const char *sourceText,
540 const char *, Encoding encoding ) const
541{
542#ifndef QT_NO_TEXTCODEC
543 if ( encoding == UnicodeUTF8 )
544 return QString::fromUtf8( sourceText );
545 else
546#endif
547 return QString::fromLatin1( sourceText );
548}
549#endif
550
551inline int QApplication::horizontalAlignment( int align )
552{
553 align &amp;= AlignHorizontal_Mask;
554 if ( align == AlignAuto ) {
555 if ( reverseLayout() )
556 align = AlignRight;
557 else
558 align = AlignLeft;
559 }
560 return align;
561}
562
563#endif // QAPPLICATION_H
564
565</pre>
566<!-- eof -->
567<p><address><hr><div align=center>
568<table width=100% cellspacing=0 border=0><tr>
569<td>Copyright &copy; 2007
570<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
571<td align=right><div align=right>Qt 3.3.8</div>
572</table></div></address></body>
573</html>
Note: See TracBrowser for help on using the repository browser.