.BI "QtMsgHandler \fBqInstallMsgHandler\fR ( QtMsgHandler h )"
.br
.in -1c
.SH DESCRIPTION
The QApplication class manages the GUI application's control flow and main settings.
.PP
It 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. It also handles most system-wide and application-wide settings.
.PP
For any GUI application that uses Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any time.
.PP
The QApplication object is accessible through the global pointer \fCqApp\fR. Its main areas of responsibility are:
.IP
.TP
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.
.IP
.TP
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.
.IP
.TP
It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details about this.
It specifies how the application is to allocate colors. See setColorSpec() for details.
.IP
.TP
It provides localization of strings that are visible to the user via translate().
.IP
.TP
It provides some magical objects like the desktop() and the clipboard().
.IP
.TP
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.
.IP
.TP
It manages the application's mouse cursor handling, see setOverrideCursor() and setGlobalMouseTracking().
.IP
.TP
On the X window system, it provides functions to flush and sync the communication stream, see flushX() and syncX().
.IP
.TP
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.
.IP
.PP
The Application walk-through example contains a typical complete main() that does the usual things with QApplication.
.PP
Since the QApplication object does so much initialization, it \fBmust\fR be created before any other objects related to the user interface are created.
.PP
Since it also deals with common command line arguments, it is usually a good idea to create it \fIbefore\fR any interpretation or modification of \fCargv\fR is done in the application itself. (Note also that for X11, setMainWidget() may change the main widget according to the \fC-geometry\fR option. To preserve this functionality, you must set your defaults before setMainWidget() and any overrides after.)
\fINon-GUI programs:\fR While TQt is not optimized or designed for writing non-GUI programs, it's possible to use some of its classes without creating a QApplication. This can be useful if you wish to share code between a non-GUI server and a GUI client.
Note that \fIargc\fR and \fIargv\fR might be changed. TQt removes command line arguments that it recognizes. The modified \fIargc\fR and \fIargv\fR can also be accessed later with \fCqApp->argc()\fR and \fCqApp->argv()\fR. The documentation for argv() contains a detailed description of how to process command line arguments.
-style= \fIstyle\fR, sets the application GUI style. Possible values are \fCmotif\fR, \fCwindows\fR, and \fCplatinum\fR. If you compiled TQt with additional styles or have additional styles as plugins these will be available to the \fC-style\fR command line option.
-display \fIdisplay\fR, sets the X display (default is $DISPLAY).
.TP
-geometry \fIgeometry\fR, sets the client geometry of the main widget.
.TP
-fn or \fC-font\fR \fIfont\fR, defines the application font. The font should be specified using an X logical font description.
.TP
-bg or \fC-background\fR \fIcolor\fR, sets the default background color and an application palette (light and dark shades are calculated).
.TP
-fg or \fC-foreground\fR \fIcolor\fR, sets the default foreground color.
.TP
-btn or \fC-button\fR \fIcolor\fR, sets the default button color.
.TP
-name \fIname\fR, sets the application name.
.TP
-title \fItitle\fR, sets the application title (caption).
.TP
-visual \fCTrueColor\fR, forces the application to use a TrueColor visual on an 8-bit display.
.TP
-ncols \fIcount\fR, 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 \fIcount\fR 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.
.TP
-cmap, causes the application to install a private color map on an 8-bit display.
Constructs an application object with \fIargc\fR command line arguments in \fIargv\fR. If \fIGUIenabled\fR is TRUE, a GUI application is constructed, otherwise a non-GUI (console) application is created.
.PP
Set \fIGUIenabled\fR to FALSE for programs without a graphical user interface that should be able to run without a window system.
.PP
On X11, the window system is initialized if \fIGUIenabled\fR is TRUE. If \fIGUIenabled\fR is FALSE, the application does not connect to the X-server. On Windows and Macintosh, currently the window system is always initialized, regardless of the value of GUIenabled. This may change in future versions of Qt.
.PP
The following example shows how to create an application that uses a graphical interface when available.
Create an application, given an already open display \fIdpy\fR. If \fIvisual\fR and \fIcolormap\fR are non-zero, the application will use those as the default Visual and Colormap contexts.
Create an application, given an already open display \fIdpy\fR and using \fIargc\fR command line arguments in \fIargv\fR. If \fIvisual\fR and \fIcolormap\fR are non-zero, the application will use those as the default Visual and Colormap contexts.
This signal is emitted when the application is about to quit the main event loop, e.g. when the event loop level drops to zero. This may happen either after a call to quit() from inside the application or when the users shuts down the entire desktop session.
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.
.PP
Modal widgets are organized in a stack. This function returns the active modal widget at the top of the stack.
.PP
See also activePopupWidget() and topLevelWidgets().
A popup widget is a special top level widget that sets the WType_Popup widget flag, e.g. the TQPopupMenu 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.
.PP
See also activeModalWidget() and topLevelWidgets().
Returns the application top-level window that has the keyboard input focus, or 0 if no application window has the focus. Note that there might be an activeWindow() even if there is no focusWidget(), for example if no widget in that window accepts key events.
The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is \fCINSTALL/plugins\fR, where \fCINSTALL\fR is the directory where TQt was installed.
For example, if you have installed TQt in the \fCC:\Trolltech\Qt\fR directory, and you run the \fCdemo\fR example, this function will return "C:/Trolltech/Qt/examples/demo".
On Mac OS X this will point to the directory actually containing the executable, which may be inside of an application bundle (if the application is bundled).
.PP
\fBWarning:\fR On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.
For example, if you have installed TQt in the \fCC:\Trolltech\Qt\fR directory, and you run the \fCdemo\fR example, this function will return "C:/Trolltech/Qt/examples/demo/demo.exe".
\fBWarning:\fR On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.
.PP
See also applicationDirPath().
.SH "int QApplication::argc () const"
Returns the number of command line arguments.
.PP
The documentation for argv() describes how to process command line arguments.
.PP
See also argv() and QApplication::QApplication().
.PP
Examples:
.)l chart/main.cpp and scribble/scribble.cpp.
.SH "char ** QApplication::argv () const"
Returns the command line argument vector.
.PP
\fCargv()[0]\fR is the program name, \fCargv()[1]\fR is the first argument and \fCargv()[argc()-1]\fR is the last argument.
A QApplication object is constructed by passing \fIargc\fR and \fIargv\fR from the \fCmain()\fR function. Some of the arguments may be recognized as TQt options and removed from the argument vector. For example, the X11 version of TQt knows about \fC-display\fR, \fC-font\fR and a few more options.
If you run \fCshowargs -display unix:0 -font 9x15bold hello world\fR under X11, the list box contains the three strings "showargs"," hello" and "world".
.PP
Qt provides a global pointer, \fCqApp\fR, that points to the QApplication object, and through which you can access argc() and argv() in functions other than main().
.PP
See also argc() and QApplication::QApplication().
.PP
Examples:
.)l chart/main.cpp and scribble/scribble.cpp.
.SH "void QApplication::beep ()\fC [static]\fR"
Sounds the bell, using the default volume and sound.
This function is particularly useful for applications with many top-level windows. It could, for example, be connected to a "Quit" entry in the file menu as shown in the following code example:
.PP
.nf
.br
// the "Quit" menu entry should try to close all windows
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.
.PP
Note that you should not exit the application within this function. Instead, the session manager may or may not do this afterwards, depending on the context.
\fBWarning:\fR Within this function, no user interaction is possible, \fIunless\fR you ask the session manager \fIsm\fR for explicit permission. See TQSessionManager::allowsInteraction() and TQSessionManager::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.
.PP
See also isSessionRestored(), sessionId(), saveState(), and the Session Management overview.
Returns the desktop widget (also called the root window).
.PP
The desktop widget is useful for obtaining the size of the screen. It may also be possible to draw on the desktop. We recommend against assuming that it's possible to draw on the desktop, since this does not work on all operating systems.
Enters the main event loop and waits until exit() is called or the main widget is destroyed, and 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.
.PP
Generally speaking, 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 TQTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().
.)l helpsystem/main.cpp, life/main.cpp, network/archivesearch/main.cpp, network/ftpclient/main.cpp, opengl/main.cpp, t1/main.cpp, and t4/main.cpp.
.SH "void QApplication::exit ( int retcode = 0 )\fC [static]\fR"
Tells the application to exit with a return code.
.PP
After this function has been called, the application leaves the main event loop and returns from the call to exec(). The exec() function returns \fIretcode\fR.
.PP
By convention, a \fIretcode\fR of 0 means success, and any non-zero value indicates an error.
.PP
Note that unlike the C library function of the same name, this function \fIdoes\fR return to the caller -- it is event processing that stops.
.)l chart/chartform.cpp, extension/mainform.ui.h, and picture/picture.cpp.
.SH "void QApplication::exit_loop ()"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This function exits from a recursive call to the main event loop. Do not call it unless you are an expert.
.PP
Use QApplication::eventLoop()->exitLoop() instead.
.SH "void QApplication::flush ()\fC [static]\fR"
Flushes the window system specific event queues.
.PP
If you are doing graphical changes inside a loop that does not return to the event loop on asynchronous window systems like X11 or double buffered window systems like MacOS X, and you want to visualize these changes immediately (e.g. Splash Screens), call this function.
The strut is a size object whose dimensions are the minimum 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.
Returns TRUE if global mouse tracking is enabled; otherwise returns FALSE.
.PP
See also setGlobalMouseTracking().
.SH "bool QApplication::hasPendingEvents ()"
This function returns TRUE if there are pending events; otherwise returns FALSE. Pending events can be either from the window system or posted events using QApplication::postEvent().
.SH "int QApplication::horizontalAlignment ( int align )\fC [static]\fR"
Strips out vertical alignment flags and transforms an alignment \fIalign\fR of AlignAuto into AlignLeft or AlignRight according to the language used. The other horizontal alignment flags are left untouched.
Adds the message file \fImf\fR to the list of message files to be used for translations.
.PP
Multiple message files can be installed. Translations are searched for in the last installed message file, then the one from last, and so on, back to the first installed message file. The search stops as soon as a matching translation is found.
Returns a list of paths that the application will search when dynamically loading libraries. The installation directory for plugins is the only entry if no paths have been set. The default installation directory for plugins is \fCINSTALL/plugins\fR, where \fCINSTALL\fR is the directory where TQt was installed. The directory of the application executable (NOT the working directory) is also added to the plugin paths.
Lock the TQt Library Mutex. If another thread has already locked the mutex, the calling thread will block until the other thread has unlocked the mutex.
\fBWarning:\fR Due to different implementations of recursive mutexes on the supported platforms, calling this function from the same thread that previously locked the mutex will give undefined results.
.PP
See also lock(), unlock(), and Thread Support in Qt.
.SH "int QApplication::loopLevel () const"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Returns the current loop level.
.PP
Use QApplication::eventLoop()->loopLevel() instead.
This virtual function is only implemented under Macintosh.
.PP
If you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that are received from the MacOS.
.PP
Return TRUE if you want to stop the event from being processed. Return FALSE for normal event dispatching.
Sends event \fIe\fR to \fIreceiver\fR: \fIreceiver\fR->event(\fIe\fR). Returns the value that is returned from the receiver's event handler.
.PP
For certain types of events (e.g. mouse and key events), the event will be propagated to the receiver's parent and so on up to the top-level object if the receiver is not interested in the event (i.e., it returns FALSE).
.PP
There are five different ways that events can be processed; reimplementing this virtual function is just one of them. All five approaches are listed below: <ol type=1>
Installing an event filter on tqApp. Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for disabled widgets, and if global mouse tracking is enabled, as well as mouse move events for all widgets.
Reimplementing TQObject::event() (as TQWidget does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.
If a widget is passed in \fIw\fR, the default palette for the widget's class is returned. This may or may not be the application palette. In most cases there isn't a 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.
Note that you are not limited to the public functions of TQWidget. Instead, based on meta information like TQObject::className() you are able to customize any kind of widget.
\fBNote:\fR This function is thread-safe when TQt is built withthread support.</p> Adds the event \fIevent\fR with the object \fIreceiver\fR as the receiver of the event, to an event queue and returns immediately.
It's common to connect the lastWindowClosed() signal to quit(), and you also often connect e.g. QButton::clicked() or signals in TQAction, TQPopupMenu or TQMenuBar to it.
The events are \fInot\fR dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause \fIreceiver\fR to break one or more invariants.
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.
.PP
See also setOverrideCursor() and overrideCursor().
.PP
Examples:
.)l distributor/distributor.ui.h, network/archivesearch/archivedialog.ui.h, network/ftpclient/ftpmainwindow.ui.h, and showimg/showimg.cpp.
Returns TRUE if all dialogs and widgets will be laid out in a mirrored (right to left) fashion. Returns FALSE if dialogs and widgets will be laid out left to right.
This function deals with session management. It is invoked when the session manager wants the application to preserve its state for a future session.
.PP
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.
.PP
Note that 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.
\fBWarning:\fR Within this function, no user interaction is possible, \fIunless\fR you ask the session manager \fIsm\fR for explicit permission. See TQSessionManager::allowsInteraction() and TQSessionManager::allowsErrorInteraction() for details.
Immediately dispatches all events which have been previously queued with QApplication::postEvent() and which are for the object \fIreceiver\fR and have the event type \fIevent_type\fR.
.PP
Note that events from the window system are \fInot\fR dispatched by this function, but by processEvents().
.PP
If \fIreceiver\fR is null, the events of \fIevent_type\fR are sent for all objects. If \fIevent_type\fR is 0, all the events are sent for \fIreceiver\fR.
If the application has been restored from an earlier session, this key is the same as it was when the previous session ended.
.PP
The session key changes with every call of commitData() or saveState().
.PP
See also isSessionRestored(), sessionId(), commitData(), and saveState().
.SH "void QApplication::setColorSpec ( int spec )\fC [static]\fR"
Sets the color specification for the application to \fIspec\fR.
.PP
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.
.PP
The color specification must be set before you create the QApplication object.
.PP
The options are:
.TP
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 Windows machines 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, TQt creates a Windows palette, and allocates colors to it on demand.
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"<sup>*</sup>, but the number of colors can be changed by the \fI-ncols\fR 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 have this feature, for example. They provide an 8 bit visual by default but can deliver true color when asked. On Windows, TQt 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.
TQColor provides more functionality for controlling color allocation and freeing up certain colors. See TQColor::enterAllocContext() for more information.
To check what mode you end up with, call TQColor::numBitPlanes() once the QApplication object exists. A value greater than 8 (typically 16, 24 or 32) means true color.
<sup>*</sup> The color cube used by TQt has 216 colors whose red, green, and blue components always have one of the following values: 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF.
Sets the text cursor's flash (blink) time to \fImsecs\fR milliseconds. The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for \fImsecs/2\fR milliseconds, then hidden for \fImsecs/2\fR milliseconds, but this may vary.
By default, TQt will try to use the current standard colors, fonts etc., from the underlying window system's desktop settings, and use them for all relevant widgets. This behavior can be switched off by calling this function with \fIon\fR set to FALSE.
Changes the default application font to \fIfont\fR. If \fIinformWidgets\fR is TRUE, then existing widgets are informed about the change and may adjust themselves to the new application setting. If \fIinformWidgets\fR is FALSE, the change only affects newly created widgets. If \fIclassName\fR is passed, the change applies only to classes that inherit \fIclassName\fR (as reported by TQObject::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.
Enables global mouse tracking if \fIenable\fR is TRUE, or disables it if \fIenable\fR is FALSE.
.PP
Enabling global mouse tracking makes it possible for widget event filters or application event filters to get all mouse move events, even when no button is depressed. This is useful for special GUI elements, e.g. tooltips.
Global mouse tracking does not affect widgets and their mouseMoveEvent(). For a widget to get mouse move events when no button is depressed, it must do TQWidget::setMouseTracking(TRUE).
Sets the application's global strut to \fIstrut\fR.
.PP
The strut is a size object whose dimensions are the minimum 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.
.PP
The strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar IO-devices.
Sets the list of directories to search when loading libraries to \fIpaths\fR. All existing paths will be deleted and the path list will consist of the paths given in \fIpaths\fR.
.PP
See also libraryPaths(), addLibraryPath(), removeLibraryPath(), and QLibrary.
Sets the application's main widget to \fImainWidget\fR.
.PP
In most respects the main widget is like any other widget, except that if it is closed, the application exits. Note that QApplication does \fInot\fR take ownership of the \fImainWidget\fR, so if you create your main widget on the heap you must delete it yourself.
For X11, this function also resizes and moves the main widget according to the \fI-geometry\fR command-line option, so you should set the default geometry (using TQWidget::setGeometry()) before calling setMainWidget().
Sets the application override cursor to \fIcursor\fR.
.PP
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.
.PP
This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.
.PP
Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.
.PP
If \fIreplace\fR is TRUE, the new cursor will replace the last override cursor (the stack keeps its depth). If \fIreplace\fR is FALSE, the new stack is pushed onto the top of the stack.
Changes the default application palette to \fIpalette\fR. If \fIinformWidgets\fR is TRUE, then existing widgets are informed about the change and may adjust themselves to the new application setting. If \fIinformWidgets\fR is FALSE, the change only affects newly created widgets.
If \fIclassName\fR is passed, the change applies only to widgets that inherit \fIclassName\fR (as reported by TQObject::inherits()). If \fIclassName\fR is left 0, the change affects all widgets, thus overriding any previously set class specific palettes.
If \fIb\fR is TRUE, all dialogs and widgets will be laid out in a mirrored fashion, as required by right to left languages such as Arabic and Hebrew. If \fIb\fR is FALSE, dialogs and widgets are laid out left to right.
Sets the application's GUI style to \fIstyle\fR. 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.
.PP
Example usage:
.PP
.nf
.br
QApplication::setStyle( new QWindowsStyle );
.br
.fi
.PP
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.
The string must be one of the TQStyleFactory::keys(), typically one of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and" compact". Depending on the platform, "windowsxp", "aqua" or" macintosh" may be available.
.SH "void QApplication::setWheelScrollLines ( int n )\fC [static]\fR"
Sets the number of lines to scroll when the mouse wheel is rotated to \fIn\fR.
.PP
If this number exceeds the number of visible lines in a certain widget, the widget should interpret the scroll operation as a single page up / page down operation instead.
If you support drag and drop in you application and a drag should start after a mouse click and after moving the mouse a certain distance, you should use the value which this method returns as the distance.
.PP
For example, if the mouse position of the click is stored in \fCstartPos\fR and the current position (e.g. in the mouse move event) is \fCcurrPos\fR, you can find out if a drag should be started with code like this:
If you support drag and drop in you application and a drag should start after a mouse click and after a certain time elapsed, you should use the value which this method returns as the delay (in ms).
\fBNote:\fR This function is reentrant when TQt is built with thread support.</p> Returns the translation text for \fIsourceText\fR, by querying the installed messages files. The message files are searched from the most recently installed message file back to the first installed message file.
\fIcontext\fR is typically a class name (e.g., "MyDialog") and \fIsourceText\fR is either English text or a short identifying text, if the output text will be very long (as for help texts).
.PP
\fIcomment\fR is a disambiguating comment, for when the same \fIsourceText\fR is used in different roles within the same context. By default, it is null. \fIencoding\fR indicates the 8-bit encoding of character stings
If none of the message files contain a translation for \fIsourceText\fR in \fIcontext\fR, this function returns a TQString equivalent of \fIsourceText\fR. The encoding of \fIsourceText\fR is specified by \fIencoding\fR; it defaults to DefaultCodec.
\fBWarning:\fR This method is reentrant only if all translators are installed \fIbefore\fR calling this method. Installing or removing translators while performing translations is not supported. Doing so will most likely result in crashes or other undesirable behavior.
Attempts to lock the TQt Library Mutex, and returns immediately. If the lock was obtained, this function returns TRUE. If another thread has locked the mutex, this function returns FALSE, instead of waiting for the lock to become available.
If \fIchild\fR is FALSE and there is a child widget at position \fI(x, y)\fR, the top-level widget containing it is returned. If \fIchild\fR is TRUE the child widget at position \fI(x, y)\fR is returned.
If \fIchild\fR is FALSE and there is a child widget at position \fIpos\fR, the top-level widget containing it is returned. If \fIchild\fR is TRUE the child widget at position \fIpos\fR is returned.
This virtual function is only implemented under Windows.
.PP
The message procedure calls this function for every message received. Reimplement this function if you want to process window messages that are not processed by Qt. If you don't want the event to be processed by Qt, then return TRUE; otherwise return FALSE.
This virtual function is only implemented under X11.
.PP
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.
.PP
Return TRUE if you want to stop the event from being processed. Return FALSE for normal event dispatching.
It returns 1 if the event was consumed by special handling, 0 if the \fIevent\fR was consumed by normal handling, and -1 if the \fIevent\fR was for an unrecognized widget.
.PP
See also x11EventFilter().
.SH RELATED FUNCTION DOCUMENTATION
.SH "void Q_ASSERT ( bool test )"
Prints a warning message containing the source code file name and line number if \fItest\fR is FALSE.
Adds a global routine that will be called from the QApplication destructor. This function is normally used to add cleanup routines for program-wide functionality.
.PP
The function given by \fIp\fR should take no arguments and return nothing, like this:
Note that for an application- or module-wide cleanup, tqAddPostRoutine() is often not suitable. People have a tendency to make such modules dynamically loaded, and then unload those modules long before the QApplication destructor is called, for example.
For modules and libraries, using a reference-counted initialization manager or Qt' parent-child delete mechanism may be better. Here is an example of a private class which uses the parent-child mechanism to call a cleanup function at the right time:
The message handler is a function that prints out debug messages, warnings and fatal error messages. The TQt library (debug version) contains hundreds of warning messages that are printed when internal errors (usually invalid function arguments) occur. If you implement your own message handler, you get total control of these messages.
The default message handler prints the message to the standard output under X11 or to the debugger under Windows. If it is a fatal message, the application aborts immediately.
.PP
Only one message handler can be defined, since this is usually done on an application-wide basis to control debug output.
.PP
To restore the message handler, call \fCqInstallMsgHandler(0)\fR.
The system's word size in bits (typically 32) is returned in \fI*wordSize\fR. The \fI*bigEndian\fR is set to TRUE if this is a big-endian machine, or to FALSE if this is a little-endian machine.
In debug mode, this function calls tqFatal() with a message if the computer is truly weird (i.e. different endianness for 16 bit and 32 bit integers); in release mode it returns FALSE.
Prints the message \fImsg\fR and uses \fIcode\fR to get a system specific error message. When \fIcode\fR is -1 (the default), the system's last error code will be used if possible. Use this method to handle failures in platform specific API calls.
The \fCTQT_VERSION\fR define has the numeric value in the form: 0xmmiibb (m = major, i = minor, b = bugfix). For example, TQt 3.0.5's \fCTQT_VERSION\fR is 0x030005.