The QApplication class manages the application event queue. (details) (complete member list)
#include <qapp.h>
The QApplication class is central to Qt. It receives events from the underlying window system and sends them to the destination widgets. An application object must be created before any widgets can be created!
Only one single QApplication object should be created, and this is
normally done in the main() function. When a QApplication object has
been created, qApp
(defined as extern QApplication
*qApp
) will refer to this object.
Here is a complete Qt application:
#include <qapp.h>
#include <qpushbt.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv ); // create app object
QPushButton hi( "Hello, world" ); // create main widget
hi.show(); // show widget
return a.exec( &hi ); // main event loop
}
Notice that the QApplication object must be created before the widget is defined!
Creates an application object with the command line parameters argc
and argv. The qApp
will be set to point to this
application object.
Only one application object should be created. This application object must be constructed before any paint devices (includes widgets, pixmaps, bitmaps etc.)
The UNIX/X-Windows version of Qt recognizes these command line options:
Closes all widgets and cleans up all window system resources.
Sets qApp
to 0.
Returns the application cursor. This function returns 0 if no application cursor has been defined.
See also: setCursor().
Returns the desktop widget (also called root window).
The desktop widget is useful for obtaining the size of the screen. It can also be used to draw on the desktop.
QWidget *d = QApplication::desktop();
d->height(); // height of display
d->width(); // width of display
d->setBackgroundColor( red );
This function enters the main event loop (recursively). Do not call it unless you are an expert.
See also: exit_loop().
Enters the main event loop and waits until quit() is called or mainWidget is destroyed. Returns the value that was specified to quit().
As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widget have a local event loop. All programs must call exec() to activate other types of widgets.
This function leaves from a recursive call to the main event loop. Do not call it unless you are an expert.
See also: enter_loop().
Flushes the X event queue in the X-Windows implementation. Does nothing on other platforms.
Returns the default application font. There will always be an application font.
See also: setFont().
Returns the widget that was specified to exec().
Sends event to receiver: receiver->event( event );
Returns the value that was returned from the event handler.
All Qt events are sent using the notify function. Since this function is virtual, you can make a subclass of QApplication and reimplement notify() to get total control of Qt events.
See also: QObject::event().
Stores the event in a queue and returns immediatly.
Back in the main event loop, all events that are stored in the queue will be sent using the notify() function.
See also: sendEvent().
Restores after some application cursor was set.
See also: setCursor().
Sends an event directly to a receiver, using the notify() function. Returns the value that was returned from the event handler.
See also: postEvent().
Sets the application cursor to c.
This cursor will be displayed in all application widgets until restoreCursor() is called.
Example of use:
QApplication::setCursor( hourGlassCursor );
calculate_mandelbrot(); // this takes time...
QApplication::restoreCursor();
See also: cursor(), restoreCursor().
Changes the default application font to f.
If updateAllWidgets is TRUE, then this font will be set for all existing widgets. If updateAllWidgets is FALSE (default), then only widgets created after this call will have this font.
Changes the default application palette to p.
If updateAllWidgets is TRUE, then this palette will be set for all existing widgets. If updateAllWidgets is FALSE (default), then only widgets that are created after this call will have the palette.
Returns the GUI style of the application.
See also: setStyle().
Synchronizes with the X server in the X-Windows implementation. Does nothing on other platforms.
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: