Qt Jambi Home

com.trolltech.qt.gui
Class QApplication

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.core.QCoreApplication
                  extended by com.trolltech.qt.gui.QApplication
All Implemented Interfaces:
QtJambiInterface

public class QApplication
extends QCoreApplication

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

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.

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. For non-GUI Qt applications, use QCoreApplication instead, which doesn't depend on the QtGui library.

The QApplication object is accessible through the instance function which return a pointer equivalent to the global qApp pointer.

QApplication's main areas of responsibility are:

Since the QApplication object does so much initialization, it must be created before any other objects related to the user interface are created.

Since it 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.

Groups of functions
System settingsdesktopSettingsAware, setDesktopSettingsAware, cursorFlashTime, setCursorFlashTime, doubleClickInterval, setDoubleClickInterval, setKeyboardInputInterval, wheelScrollLines, setWheelScrollLines, palette, setPalette(), font, setFont(), fontMetrics.
Event handlingexec, processEvents, exit, quit. sendEvent, postEvent, sendPostedEvents, removePostedEvents, hasPendingEvents, notify, macEventFilter(), qwsEventFilter(), x11EventFilter(), x11ProcessEvent(), winEventFilter().
GUI Stylesstyle, setStyle.
Color usagecolorSpec, setColorSpec, qwsSetCustomColors().
Text handlinginstallTranslator, removeTranslator translate().
WidgetsallWidgets, topLevelWidgets, desktop, activePopupWidget, activeModalWidget, clipboard, focusWidget, winFocus(), activeWindow, widgetAt.
Advanced cursor handlingoverrideCursor(), setOverrideCursor, restoreOverrideCursor.
X Window System synchronizationflushX(), syncX.
Session managementisSessionRestored, sessionId, commitData, saveState.
MiscellaneouscloseAllWindows, startingUp, closingDown, type.

See Also:
QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings

Nested Class Summary
static class QApplication.ColorSpec
          See setColorSpec for full details.
static class QApplication.Type
          Press link for info on QApplication.Type
 
Nested classes/interfaces inherited from class com.trolltech.qt.core.QCoreApplication
QCoreApplication.Encoding
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QSessionManager> commitDataRequest
          This signal deals with session management.
 QSignalEmitter.Signal2<QWidget,QWidget> focusChanged
          This signal is emitted when the widget that has keyboard focus changed from old to now, i.e. because the user pressed the tab-key, clicked into a widget or changed the active window.
 QSignalEmitter.Signal0 lastWindowClosed
          This signal is emitted from QApplication::exec() when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed.
 QSignalEmitter.Signal1<QSessionManager> saveStateRequest
          This signal deals with session management.
 
Fields inherited from class com.trolltech.qt.core.QCoreApplication
aboutToQuit, m_instance, unixSignal
 
Constructor Summary
QApplication(java.lang.String[] args)
          Initializes the window system and constructs an application object with the command line arguments in argv.
 
Method Summary
static void aboutQt()
          Displays a simple message box about Qt.
static void aboutQtJambi()
          Displays a simple message box about Qt Jambi.
static QWidget activeModalWidget()
          Returns the active modal widget.
static QWidget activePopupWidget()
          Returns the active popup widget.
static QWidget activeWindow()
          Returns the application top-level window that has the keyboard input focus, or 0 if no application window has the focus.
static void alert(QWidget widget)
          Equivalent to alert(widget, 0).
static void alert(QWidget widget, int duration)
          Causes an alert to be shown for widget if the window is not the active window.
static java.util.List<QWidget> allWidgets()
          Returns a list of all the widgets in the application.
static void beep()
          Sounds the bell, using the default volume and sound.
static void changeOverrideCursor(QCursor arg__1)
          Changes the currently active application override cursor to arg__1.
static QClipboard clipboard()
          Returns a pointer to the application global clipboard.
static void closeAllWindows()
          Closes all top-level windows.
static int colorSpec()
          Returns the color specification.
 void commitData(QSessionManager sm)
          This function deals with session management.
static int cursorFlashTime()
          Returns the text cursor's flash (blink) time in milliseconds.
static QDesktopWidget desktop()
          Returns the desktop widget (also called the root window).
static boolean desktopSettingsAware()
          Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false.
static int doubleClickInterval()
          Returns the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.
 boolean event(QEvent arg__1)
          

This virtual function receives events to an object and should return true if the event arg__1 was recognized and processed.

The event function can be reimplemented to customize the behavior of an object.

static int exec()
          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).
static QWidget focusWidget()
          Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.
static QFont font()
          Returns the default application font.
static QFont font(QWidget arg__1)
          Returns the default font for the arg__1.
static QFontMetrics fontMetrics()
          Returns display (screen) font metrics for the application font.
static QApplication fromNativePointer(QNativePointer nativePointer)
          This function returns the QApplication instance pointed to by nativePointer
static QSize globalStrut()
          Returns the minimum size that any GUI element that the user can interact with should have.
 QInputContext inputContext()
          Returns the QInputContext instance used by the application.
static QApplication instance()
          Returns the unique QApplication instance.
static boolean isEffectEnabled(Qt.UIEffect arg__1)
          Returns true if arg__1 is enabled; otherwise returns false.
static boolean isLeftToRight()
          Returns true if the application's layout direction is Qt::LeftToRight; otherwise returns false.
static boolean isRightToLeft()
          Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.
 boolean isSessionRestored()
          Returns true if the application has been restored from an earlier session; otherwise returns false.
static Qt.LayoutDirection keyboardInputDirection()
          Returns the current keyboard input direction.
static int keyboardInputInterval()
          Returns the time limit in milliseconds that distinguishes a key press from two consecutive key presses.
static QLocale keyboardInputLocale()
          Returns the current keyboard input locale.
static Qt.KeyboardModifiers keyboardModifiers()
          Returns the current state of the modifier keys on the keyboard.
static Qt.LayoutDirection layoutDirection()
          Returns the default layout direction for this application.
static Qt.MouseButtons mouseButtons()
          Returns the current state of the buttons on the mouse.
 boolean notify(QObject arg__1, QEvent arg__2)
          

Sends arg__2 to arg__1: arg__1->event(arg__2).

static QCursor overrideCursor()
          Returns the active application override cursor.
static QPalette palette()
          Returns the application palette.
static QPalette palette(QWidget arg__1)
          If a arg__1 is passed, the default palette for the widget's class is returned.
static boolean quitOnLastWindowClosed()
          Returns whether the application implicitly quits when the last window is closed..
static void restoreOverrideCursor()
          Undoes the last setOverrideCursor.
 void saveState(QSessionManager sm)
          This function deals with session management.
 java.lang.String sessionId()
          Returns the current session's identifier.
 java.lang.String sessionKey()
          Returns the session key in the current session.
static void setActiveWindow(QWidget act)
          Sets the active window to the act widget in response to a system event.
static void setColorSpec(int arg__1)
          Sets the color specification for the application to arg__1.
static void setCursorFlashTime(int arg__1)
          Sets the text cursor's flash (blink) time in milliseconds to arg__1.
static void setDesktopSettingsAware(boolean arg__1)
          Sets whether Qt should use the system's standard colors, fonts, etc., to arg__1.
static void setDoubleClickInterval(int arg__1)
          Sets the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks to arg__1.
static void setEffectEnabled(Qt.UIEffect arg__1)
          Equivalent to setEffectEnabled(arg__1, true).
static void setEffectEnabled(Qt.UIEffect arg__1, boolean enable)
          Enables the UI effect arg__1 if enable is true, otherwise the effect will not be used.
static void setFont(QFont font)
          Changes the default application font to font.
static void setGlobalStrut(QSize arg__1)
          Sets the minimum size that any GUI element that the user can interact with should have to arg__1.
 void setInputContext(QInputContext arg__1)
          This function replaces the QInputContext instance used by the application with arg__1.
static void setKeyboardInputInterval(int arg__1)
          Sets the time limit in milliseconds that distinguishes a key press from two consecutive key presses to arg__1.
static void setLayoutDirection(Qt.LayoutDirection direction)
          Sets the default layout direction for this application to direction.
static void setOverrideCursor(QCursor arg__1)
          Sets the application override cursor to arg__1.
static void setPalette(QPalette palette)
          Changes the default application palette to palette.
static void setQuitOnLastWindowClosed(boolean quit)
          Sets whether the application implicitly quits when the last window is closed.
static void setStartDragDistance(int l)
          If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.
static void setStartDragTime(int ms)
          Sets the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin to ms.
static void setStyle(QStyle arg__1)
          Sets the application's GUI style to arg__1.
static QStyle setStyle(java.lang.String arg__1)
          Requests a QStyle object for arg__1 from the QStyleFactory.
 void setStyleSheet(java.lang.String sheet)
          Sets the application style sheet to sheet.
static void setWheelScrollLines(int arg__1)
          Sets the number of lines to scroll when the mouse wheel is rotated to arg__1.
static void setWindowIcon(QIcon icon)
          Sets the default window icon to icon.
static int startDragDistance()
          If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.
static int startDragTime()
          Returns the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin.
static QStyle style()
          Returns the application's style object.
 java.lang.String styleSheet()
          Returns the application style sheet.
static void syncX()
          Synchronizes with the X server in the X11 implementation.
static QWidget topLevelAt(int x, int y)
          Returns the top-level widget at the point (x, y); returns 0 if there is no such widget.
static QWidget topLevelAt(QPoint p)
          Returns the top-level widget at the given p; returns 0 if there is no such widget.
static java.util.List<QWidget> topLevelWidgets()
          Returns a list of the top-level widgets (windows) in the application.
static QApplication.Type type()
          Returns the type of application (Tty, GuiClient, or GuiServer).
static int wheelScrollLines()
          Returns the number of lines to scroll when the mouse wheel is rotated.
static QWidget widgetAt(int x, int y)
          Returns the widget at global screen position (x, y), or 0 if there is no Qt widget there.
static QWidget widgetAt(QPoint p)
          Returns the widget at global screen position p, or 0 if there is no Qt widget there.
static QIcon windowIcon()
          Returns the default window icon.
 
Methods inherited from class com.trolltech.qt.core.QCoreApplication
addLibraryPath, applicationDirPath, applicationFilePath, applicationName, arguments, closingDown, disposed, exit, exit, flush, hasPendingEvents, installTranslator, invokeLater, libraryPaths, organizationDomain, organizationName, postEvent, postEvent, processEvents, processEvents, processEvents, processEvents, quit, removeLibraryPath, removePostedEvents, removePostedEvents, removeTranslator, sendEvent, sendPostedEvents, sendPostedEvents, setApplicationName, setAttribute, setAttribute, setLibraryPaths, setOrganizationDomain, setOrganizationName, startingUp, testAttribute, translate, translate, translate
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

commitDataRequest

public final QSignalEmitter.Signal1<QSessionManager> commitDataRequest

This signal deals with session management. It is emitted when the QSessionManager wants the application to commit all its data.

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.

Note that you should not exit the application when called. Instead, the session manager may or may not do this afterwards, depending on the context.

Warning: Within this signal, no user interaction is possible, unless you ask the sessionManager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details and example usage.

Note: You should use Qt::DirectConnection when connecting to this signal.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QSessionManager sessionManager)
void mySlot()
See Also:
isSessionRestored, sessionId, saveState, Session Management


focusChanged

public final QSignalEmitter.Signal2<QWidget,QWidget> focusChanged

This signal is emitted when the widget that has keyboard focus changed from old to now, i.e. because the user pressed the tab-key, clicked into a widget or changed the active window. Note that both old and now can be the null-pointer.

The signal is emitted after both widget have been notified about the change through QFocusEvent.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QWidget old, com.trolltech.qt.gui.QWidget now)
void mySlot(com.trolltech.qt.gui.QWidget old)
void mySlot()
See Also:
QWidget::setFocus, QWidget::clearFocus, Qt::FocusReason


lastWindowClosed

public final QSignalEmitter.Signal0 lastWindowClosed

This signal is emitted from QApplication::exec() when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed.

By default,

This feature be turned off by setting quitOnLastWindowClosed to false.

Compatible Slot Signature:
void mySlot()
See Also:
QWidget::close


saveStateRequest

public final QSignalEmitter.Signal1<QSessionManager> saveStateRequest

This signal deals with session management. It is invoked when the session manager wants the application to preserve its state for a future session.

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.

Note that you should never exit the application within this signal. 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.

Warning: Within this function, no user interaction is possible, unless you ask the sessionManager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details.

Note:: You should use Qt::DirectConnection when connecting to this signal.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QSessionManager sessionManager)
void mySlot()
See Also:
isSessionRestored, sessionId, commitData, Session Management

Constructor Detail

QApplication

public QApplication(java.lang.String[] args)
Initializes the window system and constructs an application object with the command line arguments in argv.

Method Detail

inputContext

public final QInputContext inputContext()

Returns the QInputContext instance used by the application.

See Also:
setInputContext

isSessionRestored

public final boolean isSessionRestored()

Returns true if the application has been restored from an earlier session; otherwise returns false.

See Also:
sessionId, commitData, saveState

sessionId

public final java.lang.String sessionId()

Returns the current session's identifier.

If the application has been restored from an earlier session, this identifier is the same as it was in that previous session.

The session identifier is guaranteed to be unique both for different applications and for different instances of the same application.

See Also:
isSessionRestored, sessionKey, commitData, saveState

sessionKey

public final java.lang.String sessionKey()

Returns the session key in the current session.

If the application has been restored from an earlier session, this key is the same as it was when the previous session ended.

The session key changes with every call of commitData or saveState.

See Also:
isSessionRestored, sessionId, commitData, saveState

setInputContext

public final void setInputContext(QInputContext arg__1)

This function replaces the QInputContext instance used by the application with arg__1.

See Also:
inputContext

setStyleSheet

public final void setStyleSheet(java.lang.String sheet)

Sets the application style sheet to sheet.

See Also:
styleSheet, QWidget::setStyle, Qt Style Sheets

styleSheet

public final java.lang.String styleSheet()

Returns the application style sheet.

See Also:
setStyleSheet, QWidget::setStyle, Qt Style Sheets

commitData

public void commitData(QSessionManager sm)

This function deals with session management. It is invoked when the QSessionManager wants the application to commit all its data.

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.

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.

Warning: Within this function, no user interaction is possible, unless you ask the sm for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::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.

See Also:
isSessionRestored, sessionId, saveState, Session Management

event

public boolean event(QEvent arg__1)

This virtual function receives events to an object and should return true if the event arg__1 was recognized and processed.

The event function can be reimplemented to customize the behavior of an object.

Overrides:
event in class QCoreApplication
See Also:
installEventFilter, timerEvent, QApplication::sendEvent, QApplication::postEvent, QWidget::event

notify

public boolean notify(QObject arg__1,
                      QEvent arg__2)

Sends arg__2 to arg__1: arg__1->event(arg__2). Returns the value that is returned from the receiver's event handler.

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).

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:

  1. Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way.
  2. Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.
  3. Installing an event filter on QCoreApplication::instance(). 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.
  4. Reimplementing QObject::event() (as QWidget does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.
  5. Installing an event filter on the object. Such an event filter gets all the events except Tab and Shift-Tab key presses.

Overrides:
notify in class QCoreApplication
See Also:
QObject::event, installEventFilter

saveState

public void saveState(QSessionManager sm)

This function deals with session management. It is invoked when the session manager wants the application to preserve its state for a future session.

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.

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.

Warning: Within this function, no user interaction is possible, unless you ask the sm for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details.

See Also:
isSessionRestored, sessionId, commitData, Session Management

aboutQt

public static void aboutQt()

Displays a simple message box about Qt. The message includes the version number of Qt being used by the application.

This is useful for inclusion in the Help menu of an application, as shown in the Menus example.

This function is a convenience slot for QMessageBox::aboutQt().


activeModalWidget

public static QWidget activeModalWidget()

Returns the active modal widget.

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.

Modal widgets are organized in a stack. This function returns the active modal widget at the top of the stack.

See Also:
activePopupWidget, topLevelWidgets

activePopupWidget

public static QWidget activePopupWidget()

Returns the active popup widget.

A popup widget is a special top-level widget that sets the Qt::WType_Popup widget flag, e.g. the QMenu 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.

See Also:
activeModalWidget, topLevelWidgets

activeWindow

public static QWidget activeWindow()

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.

See Also:
setActiveWindow, QWidget::setFocus, QWidget::hasFocus, focusWidget

alert

public static void alert(QWidget widget)

Equivalent to alert(widget, 0).


alert

public static void alert(QWidget widget,
                         int duration)

Causes an alert to be shown for widget if the window is not the active window. The alert is shown for duration miliseconds. If duration is zero (the default), then the alert is shown indefinitely until the window becomes active again.

Currently this function does nothing on Qtopia Core.

On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock.

On Windows this causes the window's taskbar entry to flash for a time. If duration is zero, the flashing will stop and the taskbar entry will turn a different color (currently orange).

On X11, this will cause the window to be marked as "demands attention", the window must not be hidden (i.e. not have hide() called on it, but be visible in some sort of way) in order for this to work.


allWidgets

public static java.util.List<QWidget> allWidgets()

Returns a list of all the widgets in the application.

The list is empty (QList::isEmpty()) if there are no widgets.

Note that some of the widgets may be hidden.

Example:

    void updateAllWidgets()
    {
        foreach (QWidget *widget, QApplication::allWidgets())
            widget->update();
    }

See Also:
topLevelWidgets, QWidget::isVisible

beep

public static void beep()

Sounds the bell, using the default volume and sound. The function is not available in Qtopia Core.


changeOverrideCursor

public static void changeOverrideCursor(QCursor arg__1)

Changes the currently active application override cursor to arg__1.

This function has no effect if setOverrideCursor wasn't called.

See Also:
setOverrideCursor, overrideCursor, restoreOverrideCursor, QWidget::setCursor

clipboard

public static QClipboard clipboard()

Returns a pointer to the application global clipboard.


closeAllWindows

public static void closeAllWindows()

Closes all top-level windows.

This function is particularly useful for applications with many top-level windows. It could, for example, be connected to a Exit entry in the File menu:

        exitAct = new QAction(tr("E&xit"), this);
        exitAct->setShortcut(tr("Ctrl+Q"));
        exitAct->setStatusTip(tr("Exit the application"));
        connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));

The windows are closed in random order, until one window does not accept the close event. The application quits when the last window was successfully closed; this can be turned off by setting quitOnLastWindowClosed to false.

See Also:
quitOnLastWindowClosed, lastWindowClosed, QWidget::close, QWidget::closeEvent, lastWindowClosed, quit, topLevelWidgets, QWidget::isWindow

colorSpec

public static int colorSpec()

Returns the color specification.

See Also:
QApplication::setColorSpec

cursorFlashTime

public static int cursorFlashTime()

Returns the text cursor's flash (blink) time in milliseconds.

The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time, but this may vary.

The default value on X11 is 1000 milliseconds. On Windows, the control panel value is used. Widgets should not cache this value since it may be changed at any time by the user changing the global desktop settings.

Note that on Microsoft Windows, setting this property sets the cursor flash time for all applications.

See Also:
setCursorFlashTime

desktop

public static QDesktopWidget desktop()

Returns the desktop widget (also called the root window).

Note that the desktop may be composed of multiple screens, so it would be incorrect, for example, to attempt to center some widget in the desktop's geometry. QDesktopWidget has various functions for obtaining useful geometries upon the desktop, such as QDesktopWidget::screenGeometry() and QDesktopWidget::availableGeometry().

On X11, it is also possible to draw on the desktop.


desktopSettingsAware

public static boolean desktopSettingsAware()

Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false. The default is true.

See Also:
setDesktopSettingsAware

doubleClickInterval

public static int doubleClickInterval()

Returns the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.

The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.

On Microsoft Windows, calling this function sets the double click interval for all applications.

See Also:
setDoubleClickInterval

exec

public static int exec()

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.

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 QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents.

See Also:
quitOnLastWindowClosed, quit, exit, processEvents, QCoreApplication::exec

focusWidget

public static QWidget focusWidget()

Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.

See Also:
QWidget::setFocus, QWidget::hasFocus, activeWindow, focusChanged

font

public static QFont font(QWidget arg__1)

Returns the default font for the arg__1.

See Also:
fontMetrics, QWidget::setFont

font

public static QFont font()

Returns the default application font.

See Also:
fontMetrics, QWidget::font

fontMetrics

public static QFontMetrics fontMetrics()

Returns display (screen) font metrics for the application font.

See Also:
font, setFont, QWidget::fontMetrics, QPainter::fontMetrics

globalStrut

public static QSize globalStrut()

Returns the minimum size 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. The strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar I/O devices.

Example:

    QSize MyWidget::sizeHint() const
    {
        return QSize(80, 25).expandedTo(QApplication::globalStrut());
    }

See Also:
setGlobalStrut

isEffectEnabled

public static boolean isEffectEnabled(Qt.UIEffect arg__1)

Returns true if arg__1 is enabled; otherwise returns false.

By default, Qt will try to use the desktop settings. Call setDesktopSettingsAware(false) to prevent this.

Note: All effects are disabled on screens running at less than 16-bit color depth.

See Also:
setEffectEnabled, Qt::UIEffect

isLeftToRight

public static boolean isLeftToRight()

Returns true if the application's layout direction is Qt::LeftToRight; otherwise returns false.

See Also:
layoutDirection, isRightToLeft

isRightToLeft

public static boolean isRightToLeft()

Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.

See Also:
layoutDirection, isLeftToRight

keyboardInputDirection

public static Qt.LayoutDirection keyboardInputDirection()

Returns the current keyboard input direction.


keyboardInputInterval

public static int keyboardInputInterval()

Returns the time limit in milliseconds that distinguishes a key press from two consecutive key presses.

The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.

See Also:
setKeyboardInputInterval

keyboardInputLocale

public static QLocale keyboardInputLocale()

Returns the current keyboard input locale.


keyboardModifiers

public static Qt.KeyboardModifiers keyboardModifiers()

Returns the current state of the modifier keys on the keyboard. The current state is updated sychronously as the event queue is emptied of events that will spontaneously change the keyboard state (QEvent::KeyPress and QEvent::KeyRelease events).

It should be noted this may not reflect the actual keys held on the input device at the time of calling but rather the modifiers as last reported in one of the above events. If no keys are being held Qt::NoModifier is returned.

See Also:
mouseButtons

layoutDirection

public static Qt.LayoutDirection layoutDirection()

Returns the default layout direction for this application.

On system start-up, the default layout direction depends on the application's language.

See Also:
setLayoutDirection, QWidget::layoutDirection, isLeftToRight, isRightToLeft

mouseButtons

public static Qt.MouseButtons mouseButtons()

Returns the current state of the buttons on the mouse. The current state is updated syncronously as the event queue is emptied of events that will spontaneously change the mouse state (QEvent::MousePress and QEvent::MouseRelease events).

It should be noted this may not reflect the actual buttons held on theinput device at the time of calling but rather the mouse buttons as last reported in one of the above events. If no mouse buttons are being held Qt::NoButton is returned.

See Also:
keyboardModifiers

palette

public static QPalette palette(QWidget arg__1)

If a arg__1 is passed, 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.

See Also:
setPalette, QWidget::palette

palette

public static QPalette palette()

Returns the application palette.

See Also:
setPalette, QWidget::palette

quitOnLastWindowClosed

public static boolean quitOnLastWindowClosed()

Returns whether the application implicitly quits when the last window is closed..

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.

See Also:
setQuitOnLastWindowClosed, quit, QWidget::close

restoreOverrideCursor

public static void restoreOverrideCursor()

Undoes the last setOverrideCursor.

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.

See Also:
setOverrideCursor, overrideCursor

setActiveWindow

public static void setActiveWindow(QWidget act)

Sets the active window to the act widget in response to a system event. The function is called from the platform specific event handlers.

Warning: This function does not set the keyboard focus to the active widget. Call QWidget::activateWindow() instead.

It sets the activeWindow and focusWidget attributes and sends proper WindowActivate/WindowDeactivate and FocusIn/FocusOut events to all appropriate widgets. The window will then be painted in active state (e.g. cursors in line edits will blink), and it will have tool tips enabled.

See Also:
activeWindow, QWidget::activateWindow

setColorSpec

public static void setColorSpec(int arg__1)

Sets the color specification for the application to arg__1.

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.

The color specification must be set before you create the QApplication object.

The options are:

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.

Example:

    int main(int argc, char *argv[])
    {
        QApplication::setColorSpec(QApplication::ManyColor);
        QApplication app(argc, argv);
        ...
        return app.exec();
    }

See Also:
colorSpec

setCursorFlashTime

public static void setCursorFlashTime(int arg__1)

Sets the text cursor's flash (blink) time in milliseconds to arg__1.

The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time, but this may vary.

The default value on X11 is 1000 milliseconds. On Windows, the control panel value is used. Widgets should not cache this value since it may be changed at any time by the user changing the global desktop settings.

Note that on Microsoft Windows, setting this property sets the cursor flash time for all applications.

See Also:
cursorFlashTime

setDesktopSettingsAware

public static void setDesktopSettingsAware(boolean arg__1)

Sets whether Qt should use the system's standard colors, fonts, etc., to arg__1. By default, this is true.

This function must be called before creating the QApplication object, like this:

    int main(int argc, char *argv[])
    {
        QApplication::setDesktopSettingsAware(false);
        QApplication app(argc, argv);
        ...
        return app.exec();
    }

See Also:
desktopSettingsAware

setDoubleClickInterval

public static void setDoubleClickInterval(int arg__1)

Sets the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks to arg__1.

The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.

On Microsoft Windows, calling this function sets the double click interval for all applications.

See Also:
doubleClickInterval

setEffectEnabled

public static void setEffectEnabled(Qt.UIEffect arg__1)

Equivalent to setEffectEnabled(arg__1, true).


setEffectEnabled

public static void setEffectEnabled(Qt.UIEffect arg__1,
                                    boolean enable)

Enables the UI effect arg__1 if enable is true, otherwise the effect will not be used.

Note: All effects are disabled on screens running at less than 16-bit color depth.

See Also:
isEffectEnabled, Qt::UIEffect, setDesktopSettingsAware

setGlobalStrut

public static void setGlobalStrut(QSize arg__1)

Sets the minimum size that any GUI element that the user can interact with should have to arg__1.

For example no button should be resized to be smaller than the global strut size. The strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar I/O devices.

Example:

    QSize MyWidget::sizeHint() const
    {
        return QSize(80, 25).expandedTo(QApplication::globalStrut());
    }

See Also:
globalStrut

setKeyboardInputInterval

public static void setKeyboardInputInterval(int arg__1)

Sets the time limit in milliseconds that distinguishes a key press from two consecutive key presses to arg__1.

The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.

See Also:
keyboardInputInterval

setLayoutDirection

public static void setLayoutDirection(Qt.LayoutDirection direction)

Sets the default layout direction for this application to direction.

On system start-up, the default layout direction depends on the application's language.

See Also:
QWidget::layoutDirection, isLeftToRight, isRightToLeft

setOverrideCursor

public static void setOverrideCursor(QCursor arg__1)

Sets the application override cursor to arg__1.

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.

This cursor will be displayed in all the application's widgets until restoreOverrideCursor or another setOverrideCursor is called.

Application cursors are stored on an internal stack. setOverrideCursor pushes the cursor onto the stack, and restoreOverrideCursor pops the active cursor off the stack. changeOverrideCursor changes the curently active application override cursor. Every setOverrideCursor must eventually be followed by a corresponding restoreOverrideCursor, otherwise the stack will never be emptied.

Example:

    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    calculateHugeMandelbrot();              // lunch time...
    QApplication::restoreOverrideCursor();

See Also:
overrideCursor, restoreOverrideCursor, changeOverrideCursor, QWidget::setCursor

setQuitOnLastWindowClosed

public static void setQuitOnLastWindowClosed(boolean quit)

Sets whether the application implicitly quits when the last window is closed. to quit.

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.

See Also:
quitOnLastWindowClosed, quit, QWidget::close

setStartDragDistance

public static void setStartDragDistance(int l)

If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.

For example, if the mouse position of the click is stored in startPos and the current position (e.g. in the mouse move event) is currentPos, you can find out if a drag should be started with code like this:

    if ((startPos - currentPos).manhattanLength() >=
            QApplication::startDragDistance())
        startTheDrag();

Qt uses this value internally, e.g. in QFileDialog.

The default value is 4 pixels.

See Also:
startDragDistance, startDragTime, QPoint::manhattanLength, Drag and Drop

setStartDragTime

public static void setStartDragTime(int ms)

Sets the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin to ms.

If you support drag and drop in your application, and want to start a drag and drop operation after the user has held down a mouse button for a certain amount of time, you should use this property's value as the delay.

Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for starting a drag.

The default value is 500 ms.

See Also:
startDragTime, startDragDistance, Drag and Drop

setStyle

public static QStyle setStyle(java.lang.String arg__1)

Requests a QStyle object for arg__1 from the QStyleFactory.

The string must be one of the QStyleFactory::keys(), typically one of "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style names are case insensitive.

Returns 0 if an unknown arg__1 is passed, otherwise the QStyle object returned is set as the application's GUI style.

Warning: To ensure that the application's style is set correctly, it is best to call this function before the QApplication constructor, if possible.


setStyle

public static void setStyle(QStyle arg__1)

Sets the application's GUI style to arg__1. 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.

Example usage:

    QApplication::setStyle(new QWindowsStyle);

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.

Note that setting the style before a palette has been set (i.e. before creating QApplication) will cause the application to use QStyle::standardPalette() for the palette.

See Also:
style, QStyle, setPalette, desktopSettingsAware

setWheelScrollLines

public static void setWheelScrollLines(int arg__1)

Sets the number of lines to scroll when the mouse wheel is rotated to arg__1.

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" or "page down" operation instead.

See Also:
wheelScrollLines

setWindowIcon

public static void setWindowIcon(QIcon icon)

Sets the default window icon to icon.

See Also:
windowIcon, QWidget::setWindowIcon, Setting the Application Icon

startDragDistance

public static int startDragDistance()

If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.

For example, if the mouse position of the click is stored in startPos and the current position (e.g. in the mouse move event) is currentPos, you can find out if a drag should be started with code like this:

    if ((startPos - currentPos).manhattanLength() >=
            QApplication::startDragDistance())
        startTheDrag();

Qt uses this value internally, e.g. in QFileDialog.

The default value is 4 pixels.

See Also:
setStartDragDistance, startDragTime, QPoint::manhattanLength, Drag and Drop

startDragTime

public static int startDragTime()

Returns the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin.

If you support drag and drop in your application, and want to start a drag and drop operation after the user has held down a mouse button for a certain amount of time, you should use this property's value as the delay.

Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for starting a drag.

The default value is 500 ms.

See Also:
setStartDragTime, startDragDistance, Drag and Drop

style

public static QStyle style()

Returns the application's style object.

See Also:
setStyle, QStyle

syncX

public static void syncX()

Synchronizes with the X server in the X11 implementation. This normally takes some time. Does nothing on other platforms.


topLevelAt

public static QWidget topLevelAt(int x,
                                 int y)

Returns the top-level widget at the point (x, y); returns 0 if there is no such widget.


topLevelAt

public static QWidget topLevelAt(QPoint p)

Returns the top-level widget at the given p; returns 0 if there is no such widget.


topLevelWidgets

public static java.util.List<QWidget> topLevelWidgets()

Returns a list of the top-level widgets (windows) in the application.

Note that some of the top-level widgets may be hidden, for example a tooltip if no tooltip is currently shown.

Example:

    void showAllHiddenTopLevelWidgets()
    {
        foreach (QWidget *widget, QApplication::topLevelWidgets()) {
            if (widget->isHidden())
                widget->show();
        }
    }

See Also:
allWidgets, QWidget::isWindow, QWidget::isHidden

type

public static QApplication.Type type()

Returns the type of application (Tty, GuiClient, or GuiServer). The type is set when constructing the QApplication object.


wheelScrollLines

public static int wheelScrollLines()

Returns the number of lines to scroll when the mouse wheel is rotated.

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" or "page down" operation instead.

See Also:
setWheelScrollLines

widgetAt

public static QWidget widgetAt(QPoint p)

Returns the widget at global screen position p, or 0 if there is no Qt widget there.

This function can be slow.

See Also:
QCursor::pos, QWidget::grabMouse, QWidget::grabKeyboard

widgetAt

public static QWidget widgetAt(int x,
                               int y)

Returns the widget at global screen position (x, y), or 0 if there is no Qt widget there.


windowIcon

public static QIcon windowIcon()

Returns the default window icon.

See Also:
QWidget::setWindowIcon, Setting the Application Icon

fromNativePointer

public static QApplication fromNativePointer(QNativePointer nativePointer)
This function returns the QApplication instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

aboutQtJambi

public static void aboutQtJambi()
Displays a simple message box about Qt Jambi. The message includes the version number of Qt being used by the application.

This is useful for inclusion in the Help menu of an application.


instance

public static QApplication instance()
Returns the unique QApplication instance.


setFont

public static void setFont(QFont font)
Changes the default application font to font.


setPalette

public static void setPalette(QPalette palette)
Changes the default application palette to palette.


overrideCursor

public static QCursor overrideCursor()
Returns the active application override cursor.

This function returns null if no application cursor has been defined (i.e. the internal cursor stack is empty).


Qt Jambi Home