The QApplication 類管理 GUI 應用程序的控製流和主要設置。 更多...
| 頭: | #include <QApplication> |
| 繼承: | QCoreApplication |
| enum | ColorSpec { NormalColor, CustomColor, ManyColor } |
| typedef | QS60MainApplicationFactory |
| enum | Type { Tty, GuiClient, GuiServer } |
|
|
| QApplication (int & argc , char ** argv ) | |
| QApplication (int & argc , char ** argv , bool GUIenabled ) | |
| QApplication (int & argc , char ** argv , Type type ) | |
| QApplication (Display * display , Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0) | |
| QApplication (Display * display , int & argc , char ** argv , Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0) | |
| QApplication (QApplication::QS60MainApplicationFactory factory , int & argc , char ** argv ) | |
| virtual | ~QApplication () |
| virtual void | commitData (QSessionManager & manager ) |
| QInputContext * | inputContext () const |
| bool | isSessionRestored () const |
| virtual bool | macEventFilter (EventHandlerCallRef caller , EventRef event ) |
| virtual bool | qwsEventFilter (QWSEvent * event ) |
| void | qwsSetCustomColors (QRgb * colorTable , int start , int numColors ) |
| virtual void | saveState (QSessionManager & manager ) |
| QString | sessionId () const |
| QString | sessionKey () const |
| void | setInputContext (QInputContext * inputContext ) |
| QString | styleSheet () const |
| virtual bool | symbianEventFilter (const QSymbianEvent * event ) |
| int | symbianProcessEvent (const QSymbianEvent * event ) |
| virtual bool | x11EventFilter (XEvent * event ) |
| int | x11ProcessEvent (XEvent * event ) |
| virtual bool | notify (QObject * receiver , QEvent * e ) |
| void | aboutQt () |
| int | autoMaximizeThreshold () const |
| bool | autoSipEnabled () const |
| void | closeAllWindows () |
| void | setAutoMaximizeThreshold (const int threshold ) |
| void | setAutoSipEnabled (const bool enabled ) |
| void | setStyleSheet (const QString & sheet ) |
| void | aboutToReleaseGpuResources () |
| void | aboutToUseGpuResources () |
| void | commitDataRequest (QSessionManager & manager ) |
| void | focusChanged (QWidget * old , QWidget * now ) |
| void | fontDatabaseChanged () |
| void | lastWindowClosed () |
| void | saveStateRequest (QSessionManager & manager ) |
| QWidget * | activeModalWidget () |
| QWidget * | activePopupWidget () |
| QWidget * | activeWindow () |
| void | alert (QWidget * widget , int msec = 0) |
| QWidgetList | allWidgets () |
| void | beep () |
| void | changeOverrideCursor (const QCursor & cursor ) |
| QClipboard * | clipboard () |
| int | colorSpec () |
| int | cursorFlashTime () |
| QDesktopWidget * | desktop () |
| bool | desktopSettingsAware () |
| int | doubleClickInterval () |
| int | exec () |
| QWidget * | focusWidget () |
| QFont | font () |
| QFont | font (const QWidget * widget ) |
| QFont | font (const char * className ) |
| QFontMetrics | fontMetrics () |
| QSize | globalStrut () |
| bool | isEffectEnabled (Qt::UIEffect effect ) |
| bool | isLeftToRight () |
| bool | isRightToLeft () |
| Qt::LayoutDirection | keyboardInputDirection () |
| int | keyboardInputInterval () |
| QLocale | keyboardInputLocale () |
| Qt::KeyboardModifiers | keyboardModifiers () |
| Qt::LayoutDirection | layoutDirection () |
| Qt::MouseButtons | mouseButtons () |
| Qt::NavigationMode | navigationMode () |
| QCursor * | overrideCursor () |
| QPalette | palette () |
| QPalette | palette (const QWidget * widget ) |
| QPalette | palette (const char * className ) |
| Qt::KeyboardModifiers | queryKeyboardModifiers () |
| bool | quitOnLastWindowClosed () |
| QDecoration & | qwsDecoration () |
| void | qwsSetDecoration (QDecoration * decoration ) |
| QDecoration * | qwsSetDecoration (const QString & decoration ) |
| void | restoreOverrideCursor () |
| void | setActiveWindow (QWidget * active ) |
| void | setColorSpec (int spec ) |
| void | setCursorFlashTime (int) |
| void | setDesktopSettingsAware (bool on ) |
| void | setDoubleClickInterval (int) |
| void | setEffectEnabled (Qt::UIEffect effect , bool enable = true) |
| void | setFont (const QFont & font , const char * className = 0) |
| void | setGlobalStrut (const QSize &) |
| void | setGraphicsSystem (const QString & system ) |
| void | setKeyboardInputInterval (int) |
| void | setLayoutDirection (Qt::LayoutDirection direction ) |
| void | setNavigationMode (Qt::NavigationMode mode ) |
| void | setOverrideCursor (const QCursor & cursor ) |
| void | setPalette (const QPalette & palette , const char * className = 0) |
| void | setQuitOnLastWindowClosed (bool quit ) |
| void | setStartDragDistance (int l ) |
| void | setStartDragTime (int ms ) |
| void | setStyle (QStyle * style ) |
| QStyle * | setStyle (const QString & style ) |
| void | setWheelScrollLines (int) |
| void | setWindowIcon (const QIcon & icon ) |
| int | startDragDistance () |
| int | startDragTime () |
| QStyle * | style () |
| void | syncX () |
| QWidget * | topLevelAt (const QPoint & point ) |
| QWidget * | topLevelAt (int x , int y ) |
| QWidgetList | topLevelWidgets () |
| 類型 | type () |
| int | wheelScrollLines () |
| QWidget * | widgetAt (const QPoint & point ) |
| QWidget * | widgetAt (int x , int y ) |
| QIcon | windowIcon () |
| virtual bool | event (QEvent * e ) |
| qApp |
The QApplication 類管理 GUI 應用程序的控製流和主要設置。
QApplication 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, finalization, and provides session management. In addition, QApplication 處理大多數係統範圍和應用程序範圍的設置。
對於使用 QT 的任何 GUI 應用程序,準確存在 one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication 代替,因為它不從屬 QtGui 庫。
The QApplication 對象可訪問透過 instance () 函數返迴指針相當於全局 qApp 指針。
QApplication 主要負責的領域:
由於
QApplication
對象會做如此多的初始化,它
must
被創建,在創建用戶界麵相關的任何其它對象之前。
QApplication
還處理常見命令行自變量。因此,創建它通常是一個好主意
before
任何解釋或修改對於
argv
的履行在應用程序本身。
另請參閱 QCoreApplication , QAbstractEventDispatcher , QEventLoop ,和 QSettings .
| 常量 | 值 | 描述 |
|---|---|---|
QApplication::NormalColor
|
0
|
the default color allocation policy |
QApplication::CustomColor
|
1
|
the same as NormalColor for X11; allocates colors to a palette on demand under Windows |
QApplication::ManyColor
|
2
|
the right choice for applications that use thousands of colors |
見 setColorSpec () for full details.
這是采用以下簽名的函數指針的 typedef:
CApaApplication *myApplicationFactory();
This typedef was introduced in Qt 4.6.
另請參閱 QApplication::QApplication ().
| 常量 | 值 | 描述 |
|---|---|---|
QApplication::Tty
|
0
|
a console application |
QApplication::GuiClient
|
1
|
a GUI client application |
QApplication::GuiServer
|
2
|
a GUI server application (for Qt for Embedded Linux) |
This property defines a threshold for auto maximizing widgets.
The auto maximize threshold is only available as part of Qt for Windows CE.
This property defines a threshold for the size of a window as a percentage of the screen size. If the minimum size hint of a window exceeds the threshold, calling show() will cause the window to be maximized automatically.
Setting the threshold to 100 or greater means that the widget will always be maximized. Alternatively, setting the threshold to 50 means that the widget will be maximized only if the vertical minimum size hint is at least 50% of the vertical screen size.
Setting the threshold to -1 disables the feature.
On Windows CE the default is -1 (i.e., it is disabled). On Windows Mobile the default is 40.
該特性在 Qt 4.4 引入。
訪問函數:
| int | autoMaximizeThreshold () const |
| void | setAutoMaximizeThreshold (const int threshold ) |
This property holds toggles automatic SIP (software input panel) visibility.
把此特性設為
true
以自動顯示 SIP 當整個 Widget 接受鍵盤輸入時。此特性僅影響有設置 WA_InputMethodEnabled 屬性的 Widget,且通常用於在擁有很少鍵 (或沒有鍵) 的設備中發起虛擬鍵盤。
The property only has an effect on platforms which use software input panels, such as Windows CE and Symbian.
默認從屬平颱。
該特性在 Qt 4.5 引入。
訪問函數:
| bool | autoSipEnabled () const |
| void | setAutoSipEnabled (const bool enabled ) |
This property holds the text cursor's flash (blink) time in milliseconds.
閃爍時間是顯示、反轉和還原插入符號顯示要求的時間。通常,文本光標的顯示為光標閃爍時間的一半,接著隱藏為相同時間數,但這可能有所不同。
在 X11,默認值為 1000 毫秒。在 Windows, 控製麵闆 值被使用且設置此特性將設置所有應用程序的光標閃爍時間。
推薦 Widget 不要緩存此值,因為它可能隨時更改,若用戶更改全局桌麵設置。
訪問函數:
| int | cursorFlashTime () |
| void | setCursorFlashTime (int) |
此特性保持區分雙擊和 2 次連續鼠標點擊的時間限製 (以毫秒為單位)。
The default value on X11 is 400 milliseconds. On Windows and Mac OS, the operating system's value is used. However, on Windows and Symbian OS, calling this function sets the double click interval for all applications.
訪問函數:
| int | doubleClickInterval () |
| void | setDoubleClickInterval (int) |
This property holds the minimum size that any GUI element that the user can interact with should have.
例如,不應將按鈕大小重置成小於全局結構大小。應考慮結構大小,當重實現可以用於觸摸屏 (或類似 I/O 設備) 的 GUI 控件時。
範例:
QSize MyWidget::sizeHint() const { return QSize(80, 25).expandedTo(QApplication::globalStrut()); }
默認情況下,此特性包含 QSize 對象具有 0 寬度和高度。
訪問函數:
| QSize | globalStrut () |
| void | setGlobalStrut (const QSize &) |
This property holds the time limit in milliseconds that distinguishes a key press from two consecutive key presses.
在 X11,默認值為 400 毫秒。在 Windows 和 Mac OS,使用操作係統的值。
該特性在 Qt 4.2 引入。
訪問函數:
| int | keyboardInputInterval () |
| void | setKeyboardInputInterval (int) |
This property holds the default layout direction for this application.
當係統啓動時,默認布局方嚮從屬應用程序的語言。
訪問函數:
| Qt::LayoutDirection | layoutDirection () |
| void | setLayoutDirection (Qt::LayoutDirection direction ) |
另請參閱 QWidget::layoutDirection , isLeftToRight (),和 isRightToLeft ().
此特性保持應用程序是否隱式離開,當關閉最後一個窗口時。
默認為 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 for sub-windows. Refer to Qt::WindowType for a detailed list of Qt::Window 對象。
訪問函數:
| bool | quitOnLastWindowClosed () |
| void | setQuitOnLastWindowClosed (bool quit ) |
另請參閱 quit () 和 QWidget::close ().
若應用程序支持拖放,且想要開始拖放操作在用戶有按下按鈕將光標移動一定距離後,應使用此特性值作為最小要求距離。
例如,若將點擊鼠標位置存儲在
startPos
且當前位置 (如:在鼠標移動事件中) 為
currentPos
, 可以找齣是否應采用像這樣的代碼啓動拖拽:
if ((startPos - currentPos).manhattanLength() >= QApplication::startDragDistance()) startTheDrag();
Qt 使用此值在內部,如在 QFileDialog .
The default value is 4 pixels.
訪問函數:
| int | startDragDistance () |
| void | setStartDragDistance (int l ) |
另請參閱 startDragTime (), QPoint::manhattanLength (),和 拖放 .
This property holds the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin.
若應用程序支持拖放,且想要開始拖放操作在用戶有按下鼠標按鈕一定時間後,應使用此特性值作為延遲。
Qt 內部也使用此延遲,如在 QTextEdit and QLineEdit ,為開始拖拽。
默認值為 500 毫秒。
訪問函數:
| int | startDragTime () |
| void | setStartDragTime (int ms ) |
另請參閱 startDragDistance () 和 拖放 .
This property holds the application style sheet.
默認情況下,此特性返迴空字符串除非用戶指定
-stylesheet
選項在命令行當運行應用程序時。
該特性在 Qt 4.2 引入。
訪問函數:
| QString | styleSheet () const |
| void | setStyleSheet (const QString & sheet ) |
另請參閱 QWidget::setStyle () 和 Qt 樣式錶 .
此特性保持 Widget 要捲動的行數,當鼠標滾輪鏇轉時。
若值超過 Widget 可見行數,Widget 應將捲動操作解釋成單 page up or page down 。若 Widget 是 項視圖類 ,那麼導緻捲動一 line 從屬小部件的設置 捲動模式 。捲動一 line 可以意味著 捲動 1 項 or 捲動 1 像素 .
默認情況下,此屬性擁有 3 值。
訪問函數:
| int | wheelScrollLines () |
| void | setWheelScrollLines (int) |
This property holds the default window icon.
訪問函數:
| QIcon | windowIcon () |
| void | setWindowIcon (const QIcon & icon ) |
另請參閱 QWidget::setWindowIcon () 和 設置應用程序圖標 .
初始化窗口係統並構造應用程序對象采用 argc 命令行自變量在 argv .
警告: 數據引用通過 argc and argv 必須保持有效對於整個生命周期 QApplication 對象。此外, argc 必須大於 0 且 argv 必須包含至少一條有效字符串。
全局
qApp
指針引用此應用程序對象。隻應創建一個應用程序對象。
此應用程序對象必須被構造先於任何 描繪設備 (包括小部件、像素圖、位圖等)。
注意: argc and argv 可能改變當 Qt 移除它識彆的命令行自變量時。
Qt debugging options (not available if Qt was compiled without the QT_DEBUG flag defined):
見 調試技術 for a more detailed explanation.
所有 Qt 程序自動支持以下命令行選項:
motif
,
windows
,和
platinum
. If you compiled Qt with additional styles or have additional styles as plugins these will be available to the
-style
命令行選項。
注意: 樣式錶文件中的相對 URL 相對於樣式錶文件路徑。
raster
and
opengl
.
The X11 version of Qt supports some traditional X11 command line options:
-font
font
, defines the application font. The font should be specified using an X logical font description. Note that this option is ignored when Qt is built with fontconfig support enabled.
-background
color
, sets the default background color and an application palette (light and dark shades are calculated).
-foreground
color
, sets the default foreground color.
-button
color
, sets the default button color.
TrueColor
, forces the application to use a TrueColor visual on an 8-bit display.
onTheSpot
makes the input appear directly in the widget, while
overTheSpot
makes the input appear in a box floating over the widget and is not inserted until the editing is done.
若 QApplication fails to open the X11 display, it will terminate the process. This behavior is consistent with most X11 applications.
另請參閱 arguments ().
Constructs an application object with argc 命令行自變量在 argv 。若 GUIenabled is true, a GUI application is constructed, otherwise a non-GUI (console) application is created.
警告: 數據引用通過 argc and argv 必須保持有效對於整個生命周期 QApplication 對象。此外, argc 必須大於 0 且 argv 必須包含至少一條有效字符串。
Set GUIenabled to false for programs without a graphical user interface that should be able to run without a window system.
On X11, the window system is initialized if GUIenabled 為 true。若 GUIenabled is false, the application does not connect to the X server. On Windows and Mac OS, currently the window system is always initialized, regardless of the value of GUIenabled. This may change in future versions of Qt.
The following example shows how to create an application that uses a graphical interface when available.
int main(int argc, char **argv) { #ifdef Q_WS_X11 bool useGUI = getenv("DISPLAY") != 0; #else bool useGUI = true; #endif QApplication app(argc, argv, useGUI); if (useGUI) { // start GUI version ... } else { // start non-GUI version ... } return app.exec(); }
Constructs an application object with argc 命令行自變量在 argv .
警告: 數據引用通過 argc and argv 必須保持有效對於整個生命周期 QApplication 對象。此外, argc 必須大於 0 且 argv 必須包含至少一條有效字符串。
With Qt for Embedded Linux, passing
QApplication::GuiServer
for
type
makes this application the server (equivalent to running with the
-qws
option).
Creates an application, given an already open display display 。若 visual and colormap are non-zero, the application will use those values as the default Visual and Colormap contexts.
警告: Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.
This function is only available on X11.
Creates an application, given an already open display and using argc 命令行自變量在 argv 。若 visual and colormap are non-zero, the application will use those values as the default Visual and Colormap contexts.
警告: Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.
This function is only available on X11.
Creates an application using the application factory given in factory , and using argc 命令行自變量在 argv . factory can be leaving, but the error will be converted to a standard exception.
This function is only available on S60.
該函數在 Qt 4.6 引入。
[虛擬]
QApplication::
~QApplication
()
清理由此應用程序分配的任何窗口係統資源。設置全局變量
qApp
為 0。
[static slot]
void
QApplication::
aboutQt
()
顯示關於 Qt 的簡單消息框。消息包括應用程序正使用的 Qt 版本號。
這很有用,對於包括 幫助 菜單的應用程序,如展示在 菜單 範例。
此函數是方便槽對於 QMessageBox::aboutQt ().
[signal]
void
QApplication::
aboutToReleaseGpuResources
()
This signal is emitted when application is about to release all GPU resources associated to contexts owned by application.
The signal is particularly useful if your application has allocated GPU resources directly apart from Qt and needs to do some last-second cleanup.
警告: This signal is only emitted on Symbian.
This function was introduced in Qt 4.7.4.
另請參閱 aboutToUseGpuResources ().
[signal]
void
QApplication::
aboutToUseGpuResources
()
This signal is emitted when application is about to use GPU resources.
The signal is particularly useful if your application needs to know when GPU resources are be available.
警告: This signal is only emitted on Symbian.
This function was introduced in Qt 4.7.4.
另請參閱 aboutToReleaseGpuResources ().
[static]
QWidget
* QApplication::
activeModalWidget
()
返迴活動的模態 Widget。
模態 Widget 是特殊頂層 Widget 是子類化的 QDialog 將構造函數的模態參數指定為 true。必須關閉模態 Widget 在用戶可以繼續程序的其它部分之前。
模態 Widget 被組織在堆棧中。此函數返迴堆棧頂部的活動模態 Widget。
另請參閱 activePopupWidget () 和 topLevelWidgets ().
[static]
QWidget
* QApplication::
activePopupWidget
()
返迴活動彈齣 Widget。
彈齣 Widget 是特殊頂層 Widget 有設置
Qt::WType_Popup
小部件標誌,如
QMenu
小部件。當應用程序打開彈齣 Widget 時,所有事件會被發送給彈齣 Widget。正常 Widget 和模態 Widget 無法訪問,在關閉彈齣 Widget 之前。
隻能打開其它彈齣 Widget,當展示彈齣 Widget 時。彈齣 Widget 被組織在堆棧中。此函數返迴在堆棧頂部的活動彈齣 Widget。
另請參閱 activeModalWidget () 和 topLevelWidgets ().
[static]
QWidget
* QApplication::
activeWindow
()
返迴擁有鍵盤輸入聚焦的應用程序頂層窗口,或 0 若沒有應用程序窗口擁有聚焦。可能有 activeWindow() 即使沒有 focusWidget (),例如:若該窗口的 Widget 不接受鍵事件。
另請參閱 setActiveWindow (), QWidget::setFocus (), QWidget::hasFocus (),和 focusWidget ().
[static]
void
QApplication::
alert
(
QWidget
*
widget
,
int
msec
= 0)
導緻展示警報 widget 若窗口不是活動窗口。展示警報 msec 毫秒。若 msec 為 0 (默認),則無限期展示警報,直到窗口再次變為活動為止。
目前,此函數在 Qt for Embedded Linux 什麼都不做。
On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock.
在 Windows,這導緻窗口的任務欄條目會閃爍一段時間。若 msec 為 0,閃爍會停止,且任務欄條目將變成不同顔色 (目前為橙色)。
在 X11,這導緻窗口會被標記成 "要求關注",窗口不得隱藏 (即:沒有對它調用 hide(),但以某種方式可見) 為讓這能工作。
該函數在 Qt 4.3 引入。
[static]
QWidgetList
QApplication::
allWidgets
()
返迴應用程序的所有 Widget 的列錶。
列錶為空 ( QList::isEmpty ()) 若沒有 Widget。
注意: 某些 Widget 可能被隱藏。
範例:
void updateAllWidgets() { foreach (QWidget *widget, QApplication::allWidgets()) widget->update(); }
另請參閱 topLevelWidgets () 和 QWidget::isVisible ().
[static]
void
QApplication::
beep
()
發齣鈴聲,使用默認音量和聲音。函數 not 可用於 Qt for Embedded Linux。
[static]
void
QApplication::
changeOverrideCursor
(const
QCursor
&
cursor
)
將當前活動應用程序的覆蓋光標改為 cursor .
此函數不起作用若 setOverrideCursor () 未被調用。
另請參閱 setOverrideCursor (), overrideCursor (), restoreOverrideCursor (),和 QWidget::setCursor ().
[static]
QClipboard
* QApplication::
clipboard
()
Returns a pointer to the application global clipboard.
注意: The QApplication object should already be constructed before accessing the clipboard.
[static slot]
void
QApplication::
closeAllWindows
()
關閉所有頂層窗口。
此函數尤其有用,對於具有很多頂層窗口的應用程序而言。例如,可以將它連接到 Exit 條目在 File 菜單:
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
窗口按隨機次序關閉,直到某個窗口不接受關閉事件為止。應用程序離開,當成功關閉最後一個窗口時;可以關閉這通過設置 quitOnLastWindowClosed 為 false。
另請參閱 quitOnLastWindowClosed , lastWindowClosed (), QWidget::close (), QWidget::closeEvent (), lastWindowClosed (), quit (), topLevelWidgets (),和 QWidget::isWindow ().
[static]
int
QApplication::
colorSpec
()
Returns the color specification.
另請參閱 QApplication::setColorSpec ().
[虛擬]
void
QApplication::
commitData
(
QSessionManager
&
manager
)
This function deals with 會話管理 。它被援引當 QSessionManager 想要應用程序提交其所有數據。
通常這意味著保存所有打開文件,在從用戶獲得權限後。此外,可能想要提供由用戶可以取消關閉的手段。
You should not exit the application within this function. Instead, the session manager may or may not do this afterwards, depending on the context.
警告: Within this function, no user interaction is possible, unless 要求 manager 明確權限。見 QSessionManager::allowsInteraction () 和 QSessionManager::allowsErrorInteraction () 瞭解細節和範例用法。
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.
另請參閱 isSessionRestored (), sessionId (), saveState (),和 會話管理 .
[signal]
void
QApplication::
commitDataRequest
(
QSessionManager
&
manager
)
此信號處理 會話管理 。它被發射當 QSessionManager 想要應用程序提交其所有數據。
通常這意味著保存所有打開文件,在從用戶獲得權限後。此外,可能想要提供由用戶可以取消關閉的手段。
不應退齣應用程序,在此信號內。相反,會話管理器可以 (或不可以) 之後這樣做,從屬上下文。
警告: 在此信號內,不可能進行用戶交互, unless 要求 manager 明確權限。見 QSessionManager::allowsInteraction () 和 QSessionManager::allowsErrorInteraction () 瞭解細節和範例用法。
注意: 應使用 Qt::DirectConnection 當連接到此信號時。
該函數在 Qt 4.2 引入。
另請參閱 isSessionRestored (), sessionId (), saveState (),和 會話管理 .
[static]
QDesktopWidget
* QApplication::
desktop
()
返迴桌麵 Widget (也稱根窗口)。
桌麵可能由多個屏幕組成,因此它將是不正確的,例如:試圖 center 某個 Widget 在桌麵幾何體中。 QDesktopWidget 擁有各種用於獲得桌麵上有用幾何體的函數,譬如 QDesktopWidget::screenGeometry () 和 QDesktopWidget::availableGeometry ().
在 X11,在桌麵上繪製也是可能的。
[static]
bool
QApplication::
desktopSettingsAware
()
Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false. The default is true.
另請參閱 setDesktopSettingsAware ().
[virtual protected]
bool
QApplication::
event
(
QEvent
*
e
)
重實現自 QObject::event ().
[static]
int
QApplication::
exec
()
進入主事件循環並等待,直到 exit () 被調用,然後將設置值返迴給 exit () (為 0 若 exit () 被調用憑藉 quit ()).
有必要調用此函數以啓動事件處理。主事件循環從窗口係統接收事件,並將其分派給應用程序 Widget。
一般來說,在調用 exec() 之前不會發生用戶交互。作為特殊情況,模態 Widget 像 QMessageBox 可以在調用 exec() 之前使用,因為模態 Widget 會調用 exec() 以啓動本地事件循環。
要使應用程序履行空閑處理 (即:執行特殊函數,每當沒有待決事件時),使用 QTimer 采用 0 超時。更高級空閑處理方案可以達成使用 processEvents ().
推薦把清理代碼連接到
aboutToQuit()
信號,而不是將它放入應用程序的
main()
函數。這是因為,在某些平颱調用 QApplication::exec() 可能不返迴。例如,在 Windows 平颱,當用戶注銷時,係統會在 Qt 關閉所有頂層窗口後終止進程。因此,
不保證
應用程序會有時間退齣其事件循環並執行代碼結束
main()
函數,在調用 QApplication::exec() 後。
另請參閱 quitOnLastWindowClosed , quit (), exit (), processEvents (),和 QCoreApplication::exec ().
[signal]
void
QApplication::
focusChanged
(
QWidget
*
old
,
QWidget
*
now
)
此信號發射,當 Widget 鍵盤聚焦的改變是從 old to now ,即,由於用戶按下 tab 鍵、點擊 Widget,或改變活動窗口。兩者 old and now 可以是 null 指針。
信號發射,後於兩者 Widget 被通知即將改變透過 QFocusEvent .
該函數在 Qt 4.1 引入。
另請參閱 QWidget::setFocus (), QWidget::clearFocus (),和 Qt::FocusReason .
[static]
QWidget
* QApplication::
focusWidget
()
返迴擁有鍵盤輸入聚焦的應用程序 Widget,或 0 若此應用程序的 Widget 不擁有聚焦。
另請參閱 QWidget::setFocus (), QWidget::hasFocus (), activeWindow (),和 focusChanged ().
[static]
QFont
QApplication::
font
()
返迴應用程序的默認字體。
另請參閱 setFont (), fontMetrics (),和 QWidget::font ().
[static]
QFont
QApplication::
font
(const
QWidget
*
widget
)
這是重載函數。
返迴默認字體,為 widget .
另請參閱 fontMetrics () 和 QWidget::setFont ().
[static]
QFont
QApplication::
font
(const
char
*
className
)
這是重載函數。
返迴 Widget 字體為給定 className .
另請參閱 setFont () 和 QWidget::font ().
[signal]
void
QApplication::
fontDatabaseChanged
()
此信號發射,當加載 (或移除) 應用程序字體時。
該函數在 Qt 4.5 引入。
另請參閱 QFontDatabase::addApplicationFont (), QFontDatabase::addApplicationFontFromData (), QFontDatabase::removeAllApplicationFonts (),和 QFontDatabase::removeApplicationFont ().
[static]
QFontMetrics
QApplication::
fontMetrics
()
返迴用於應用程序字體的顯示 (屏幕) 字體規格。
另請參閱 font (), setFont (), QWidget::fontMetrics (),和 QPainter::fontMetrics ().
返迴 QInputContext instance used by the application.
另請參閱 setInputContext ().
[static]
bool
QApplication::
isEffectEnabled
(
Qt::UIEffect
effect
)
返迴 true 若 effect is enabled; otherwise returns false.
默認情況下,Qt 試著使用桌麵設置。要阻止這,調用 setDesktopSettingsAware (false).
注意: 所有效果被禁用,當運行在低於 16 位顔色深度的屏幕。
另請參閱 setEffectEnabled () 和 Qt::UIEffect .
[static]
bool
QApplication::
isLeftToRight
()
Returns true if the application's layout direction is Qt::LeftToRight ;否則返迴 false。
另請參閱 layoutDirection () 和 isRightToLeft ().
[static]
bool
QApplication::
isRightToLeft
()
Returns true if the application's layout direction is Qt::RightToLeft ;否則返迴 false。
另請參閱 layoutDirection () 和 isLeftToRight ().
Returns true if the application has been restored from an earlier session ;否則返迴 false。
另請參閱 sessionId (), commitData (),和 saveState ().
[static]
Qt::LayoutDirection
QApplication::
keyboardInputDirection
()
Returns the current keyboard input direction.
該函數在 Qt 4.2 引入。
[static]
QLocale
QApplication::
keyboardInputLocale
()
Returns the current keyboard input locale.
該函數在 Qt 4.2 引入。
[static]
Qt::KeyboardModifiers
QApplication::
keyboardModifiers
()
返迴鍵盤修飾符鍵的當前狀態。當前狀態會被同步更新,當事件隊列中的自發改變鍵盤狀態的事件被清空時 ( QEvent::KeyPress and QEvent::KeyRelease 事件)。
應注意,這可能不反映調用時在輸入設備上保持的實際鍵,但反映上述事件之一最後報告的修飾符。若沒有保持鍵, Qt::NoModifier 被返迴。
另請參閱 mouseButtons () 和 queryKeyboardModifiers ().
[signal]
void
QApplication::
lastWindowClosed
()
此信號被發射從 QApplication::exec () when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed.
默認情況下,
This feature can be turned off by setting quitOnLastWindowClosed 為 false。
另請參閱 QWidget::close ().
[虛擬]
bool
QApplication::
macEventFilter
(
EventHandlerCallRef
caller
,
EventRef
event
)
警告: This virtual function is only used under Mac OS X, and behaves different depending on if Qt is based on Carbon or Cocoa.
For the Carbon port, If you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that Qt registers for from Mac OS X with this function being called with the caller 和 event .
For the Cocoa port, If you create an application that inherits QApplication and reimplement this function, you get direct access to all Cocoa Events that Qt receives from Mac OS X with this function being called with the caller being 0 and the event being an NSEvent pointer:
NSEvent *e = reinterpret_cast<NSEvent *>(event);
Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.
[static]
Qt::MouseButtons
QApplication::
mouseButtons
()
返迴鼠標按鈕的當前狀態。當前狀態是同步更新的,因為事件隊列會清空自發改變鼠標狀態的事件 ( QEvent::MouseButtonPress and QEvent::MouseButtonRelease 事件)。
應該注意的是,這可能不反映調用時輸入設備保持的實際按鈕,而是某一上述事件最後報告的鼠標按鈕。若未按住鼠標按鈕 Qt::NoButton 被返迴。
另請參閱 keyboardModifiers ().
[static]
Qt::NavigationMode
QApplication::
navigationMode
()
返迴 Qt 使用哪種聚焦導航。
This feature is available in Qt for Embedded Linux, Symbian and Windows CE only.
注意: On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined.
注意: On Symbian, the default mode is Qt::NavigationModeNone for touch devices, and Qt::NavigationModeKeypadDirectional .
該函數在 Qt 4.6 引入。
另請參閱 setNavigationMode () 和 keypadNavigationEnabled ().
[虛擬]
bool
QApplication::
notify
(
QObject
*
receiver
,
QEvent
*
e
)
重實現自 QCoreApplication::notify ().
[static]
QCursor
* QApplication::
overrideCursor
()
返迴活動應用程序的覆蓋光標。
此函數返迴 0 若應用程序光標未定義 (即:內部光標堆棧為空)。
另請參閱 setOverrideCursor () 和 restoreOverrideCursor ().
[static]
QPalette
QApplication::
palette
()
Returns the application palette.
另請參閱 setPalette () 和 QWidget::palette ().
[static]
QPalette
QApplication::
palette
(const
QWidget
*
widget
)
這是重載函數。
若 widget 有傳遞,返迴 Widget 類的默認調色闆。這可能 (或不可能) 是應用程序調色闆。在大多數情況下,某些類型的 Widget 沒有特殊調色闆,但值得注意的一例外是 Windows 下的彈齣菜單,若用戶有為顯示菜單,設置定義瞭特殊背景色。
另請參閱 setPalette () 和 QWidget::palette ().
[static]
QPalette
QApplication::
palette
(const
char
*
className
)
這是重載函數。
返迴用於 Widget 的調色闆為給定 className .
另請參閱 setPalette () 和 QWidget::palette ().
[static]
Qt::KeyboardModifiers
QApplication::
queryKeyboardModifiers
()
查詢並返迴鍵盤修飾符鍵的狀態。不像 keyboardModifiers 此方法返迴調用方法時保持在輸入設備上的實際鍵。
它不依賴必須由此進程接收的鍵按下事件,譬如:這使得當移動窗口時校驗修飾符成為可能。注意:在大多數情況下,應使用 keyboardModifiers (),其更快更準確,因為它包含的修飾符狀態 (如同接收當前處理事件時狀態)。
該函數在 Qt 4.8 引入。
另請參閱 keyboardModifiers ().
[static]
QDecoration
& QApplication::
qwsDecoration
()
Return the QWSDecoration used for decorating windows.
警告: This method is non-portable. It is only available in Qt for Embedded Linux.
另請參閱 QDecoration .
[虛擬]
bool
QApplication::
qwsEventFilter
(
QWSEvent
*
event
)
This virtual function is only implemented under Qt for Embedded Linux.
If you create an application that inherits QApplication and reimplement this function, you get direct access to all QWS (Q Window System) events that the are received from the QWS master process. The events are passed in the event 參數。
Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.
Set Qt for Embedded Linux custom color table.
Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. The remaining 40 colors may be used by setting a custom color table in the QWS master process before any clients connect.
colorTable is an array of up to 40 custom colors. start is the starting index (0-39) and numColors is the number of colors to be set (1-40).
This method is non-portable. It is available only in Qt for Embedded Linux.
注意: The custom colors will not be used by the default screen driver. To make use of the new colors, implement a custom screen driver, or use QDirectPainter .
[static]
void
QApplication::
qwsSetDecoration
(
QDecoration
*
decoration
)
設置 QDecoration derived class to use for decorating the windows used by Qt for Embedded Linux to the decoration 指定。
This method is non-portable. It is only available in Qt for Embedded Linux.
另請參閱 QDecoration .
[static]
QDecoration
* QApplication::
qwsSetDecoration
(const
QString
&
decoration
)
這是重載函數。
請求 QDecoration 對象為 decoration 從 QDecorationFactory .
字符串必須是某一 QDecorationFactory::keys (). Keys are case insensitive.
A later call to the QApplication constructor will override the requested style when a "-style" option is passed in as a commandline parameter.
返迴 0 若未知 decoration 被傳遞,否則 QStyle 返迴對象被設為應用程序的 GUI 樣式。
[static]
void
QApplication::
restoreOverrideCursor
()
撤消最後 setOverrideCursor ().
若 setOverrideCursor () 被調用 2 次,調用 restoreOverrideCursor() 將激活第 1 次光標設置。第 2 次調用此函數將還原 Widget 的原始光標。
另請參閱 setOverrideCursor () 和 overrideCursor ().
[虛擬]
void
QApplication::
saveState
(
QSessionManager
&
manager
)
This function deals with 會話管理 。它被援引當 會話管理器 想要應用程序為未來會話保留其狀態。
例如,文本編輯器將創建臨時文件 (包括當前編輯緩衝內容、光標位置及當前編輯會話的其它方麵)。
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.
警告: Within this function, no user interaction is possible, unless 要求 manager 明確權限。見 QSessionManager::allowsInteraction () 和 QSessionManager::allowsErrorInteraction () 瞭解細節。
另請參閱 isSessionRestored (), sessionId (), commitData (),和 會話管理 .
[signal]
void
QApplication::
saveStateRequest
(
QSessionManager
&
manager
)
此信號處理 會話管理 。它被援引當 會話管理器 想要應用程序為未來會話保留其狀態。
例如,文本編輯器將創建臨時文件 (包括當前編輯緩衝內容、光標位置及當前編輯會話的其它方麵)。
從不應該在此信號內退齣應用程序。相反,會話管理器可以 (或不可以) 在之後履行此,從屬上下文。更進一步,大多數會話管理器很可能會立即請求保存狀態 (在應用程序啓動後)。這準許會話管理器瞭解應用程序的重啓策略。
警告: Within this function, no user interaction is possible, unless 要求 manager 明確權限。見 QSessionManager::allowsInteraction () 和 QSessionManager::allowsErrorInteraction () 瞭解細節。
注意: 應使用 Qt::DirectConnection 當連接到此信號時。
該函數在 Qt 4.2 引入。
另請參閱 isSessionRestored (), sessionId (), commitData (),和 會話管理 .
返迴當前 會話的 標識符。
若應用程序已從早期會話還原,此標識符與先前會話標識符相同。會話標識符保證,對於不同應用程序和同一應用程序的不同實例是唯一的。
另請參閱 isSessionRestored (), sessionKey (), commitData (),和 saveState ().
返迴會話鍵,在當前 session .
若應用程序已從早期會話還原,此鍵與先前會話結束時的鍵相同。
The session key changes with every call of commitData () 或 saveState ().
另請參閱 isSessionRestored (), sessionId (), commitData (),和 saveState ().
[static]
void
QApplication::
setActiveWindow
(
QWidget
*
active
)
將活動窗口設為 active 小部件以響應係統事件。函數調用自平颱特定事件處理程序。
警告: 此函數做 not 設置活動 Widget 的鍵盤聚焦。調用 QWidget::activateWindow () 代替。
它設置 activeWindow () 和 focusWidget () 屬性並發送適當 WindowActivate / WindowDeactivate and FocusIn / FocusOut 事件到所有閤適 Widget。然後,將按活動狀態描繪窗口 (如:行編輯中的光標會眨眼),且它將啓用工具提示。
另請參閱 activeWindow () 和 QWidget::activateWindow ().
[static]
void
QApplication::
setColorSpec
(
int
spec
)
Sets the color specification for the application to spec .
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 對象。
The options are:
On Windows, Qt 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.
範例:
int main(int argc, char *argv[]) { QApplication::setColorSpec(QApplication::ManyColor); QApplication app(argc, argv); ... return app.exec(); }
另請參閱 colorSpec ().
[static]
void
QApplication::
setDesktopSettingsAware
(
bool
on
)
將 Qt 是否應使用係統標準顔色、字體等設為 on . By default, this is true.
此函數必須先被調用纔創建 QApplication 對象,像這樣:
int main(int argc, char *argv[]) { QApplication::setDesktopSettingsAware(false); QApplication app(argc, argv); ... return app.exec(); }
另請參閱 desktopSettingsAware ().
[static]
void
QApplication::
setEffectEnabled
(
Qt::UIEffect
effect
,
bool
enable
= true)
啓用 UI 效果 effect if enable 為 True,否則效果將不會被使用。
注意: 所有效果被禁用,當運行在低於 16 位顔色深度的屏幕。
另請參閱 isEffectEnabled (), Qt::UIEffect ,和 setDesktopSettingsAware ().
[static]
void
QApplication::
setFont
(const
QFont
&
font
, const
char
*
className
= 0)
將應用程序默認字體改為 font 。若 className 有傳遞,改變僅適用的類繼承 className (如報告通過 QObject::inherits ()).
當應用程序啓動時,默認字體從屬窗口係統。它可能因窗口係統版本和區域設置兩者而異。此函數讓您覆蓋默認字體;但覆蓋可能是壞主意,因為,例如:某些區域設置需要特大字體以支持它們的特殊字符。
警告: 不要使用此函數結閤 Qt 樣式錶 。可以使用 font 樣式錶特性定製應用程序字體。要為所有 QPushButton 設置粗體字體,設置應用程序 styleSheet () 如 " QPushButton { font: bold }"
另請參閱 font (), fontMetrics (),和 QWidget::setFont ().
[static]
void
QApplication::
setGraphicsSystem
(const
QString
&
system
)
Sets the default graphics backend to
system
, which will be used for on-screen widgets and QPixmaps. The available systems are
"native"
,
"raster"
and
"opengl"
.
There are several ways to set the graphics backend, in order of decreasing precedence:
-graphicssystem
switch
-graphicssystem
switch
If the highest precedence switch sets an invalid name, the error will be ignored and the default backend will be used.
警告: This function is only effective before the QApplication constructor is called.
注意:
The
"opengl"
option is currently experimental.
該函數在 Qt 4.5 引入。
This function replaces the QInputContext instance used by the application with inputContext .
Qt takes ownership of the given inputContext .
另請參閱 inputContext ().
[static]
void
QApplication::
setNavigationMode
(
Qt::NavigationMode
mode
)
將聚焦導航 Qt 應使用的種類設為 mode .
This feature is available in Qt for Embedded Linux, Symbian and Windows CE only.
注意: On Windows CE this feature is disabled by default for touch device mkspecs. To enable keypad navigation, build Qt with QT_KEYPAD_NAVIGATION defined.
注意: On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a virtual mouse cursor on non touchscreen devices, which is controlled by the cursor keys if there is no analog pointer device. On other platforms and on touchscreen devices, it has the same meaning as Qt::NavigationModeNone .
該函數在 Qt 4.6 引入。
另請參閱 navigationMode () 和 keypadNavigationEnabled ().
[static]
void
QApplication::
setOverrideCursor
(const
QCursor
&
cursor
)
將應用程序覆蓋光標設為 cursor .
應用程序覆蓋光標旨在嚮用戶展示應用程序處於特殊狀態,例如:在可能需要一些時間的操作期間。
此光標將顯示在所有應用程序的 Widget 中,直到 restoreOverrideCursor () 或另一 setOverrideCursor() 被調用。
應用程序光標存儲在內部堆棧中。setOverrideCursor() 將光標壓入堆棧,而 restoreOverrideCursor () 將活動光標從堆棧中彈齣。 changeOverrideCursor () 更改目前活動的應用程序覆蓋光標。
每個 setOverrideCursor() 之後最終必須跟隨相應 restoreOverrideCursor (),否則,將從不清空堆棧。
範例:
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); calculateHugeMandelbrot(); // lunch time... QApplication::restoreOverrideCursor();
另請參閱 overrideCursor (), restoreOverrideCursor (), changeOverrideCursor (),和 QWidget::setCursor ().
[static]
void
QApplication::
setPalette
(const
QPalette
&
palette
, const
char
*
className
= 0)
將應用程序默認調色闆更改為 palette .
若 className 有傳遞,改變僅應用於 Widget 有繼承 className (如報告通過 QObject::inherits ())。若 className 為 0,改變影響所有 Widget,從而覆蓋任何先前設置的類特定調色闆。
調色闆可能根據當前 GUI 風格改變在 QStyle::polish ().
警告: 不要使用此函數結閤 Qt 樣式錶 。當使用樣式錶時,可以使用 color、background-color、selection-color、selection-background-color 及 alternate-background-color 定製 Widget 調色闆。
注意: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for the Windows XP, Windows Vista, and Mac OS X styles.
另請參閱 QWidget::setPalette (), palette (),和 QStyle::polish ().
[static]
void
QApplication::
setStyle
(
QStyle
*
style
)
將應用程序的 GUI 風格設為 style 。將風格對象的所有權轉移給 QApplication ,所以 QApplication 會在應用程序退齣時刪除風格對象,或者當有設置新風格且舊風格仍是應用程序對象的父級時。
用法範例:
QApplication::setStyle(new QWindowsStyle);
當切換應用程序風格時,顔色調色闆被設迴初始顔色 (或係統默認)。這有必要,由於某些風格必須適配顔色調色闆,以完全兼容風格指南。
設置風格在設置調色闆之前,即先於創建 QApplication ,將導緻應用程序使用 QStyle::standardPalette () 對於調色闆。
警告: Qt 樣式錶目前不支持自定義 QStyle 子類。計劃在某些未來發行中解決此問題。
另請參閱 style (), QStyle , setPalette (),和 desktopSettingsAware ().
[static]
QStyle
* QApplication::
setStyle
(const
QString
&
style
)
這是重載函數。
請求 QStyle 對象為 style 從 QStyleFactory .
字符串必須是某一 QStyleFactory::keys (), typically one of "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style names are case insensitive.
返迴 0 若未知 style 被傳遞,否則 QStyle 返迴對象被設為應用程序的 GUI 樣式。
警告: 要確保應用程序樣式設置正確,最好調用此函數先於 QApplication 構造函數,若可能的話。
[static]
QStyle
* QApplication::
style
()
[虛擬]
bool
QApplication::
symbianEventFilter
(const
QSymbianEvent
*
event
)
警告: This virtual function is only available on Symbian.
If you create an application that inherits QApplication and reimplement this function, you get direct access to events that the are received from Symbian. The events are passed in the event 參數。
Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false, and does nothing with event .
該函數在 Qt 4.6 引入。
警告: This function is only available on Symbian.
This function processes an individual Symbian event event . It returns 1 if the event was handled, 0 if the event was not handled, and -1 if the event was not handled because the event is not known to Qt.
該函數在 Qt 4.6 引入。
[static]
void
QApplication::
syncX
()
Synchronizes with the X server in the X11 implementation. This normally takes some time. Does nothing on other platforms.
[static]
QWidget
* QApplication::
topLevelAt
(const
QPoint
&
point
)
返迴頂層 Widget 按給定 point ;返迴 0 若沒有這種 Widget。
[static]
QWidget
* QApplication::
topLevelAt
(
int
x
,
int
y
)
這是重載函數。
返迴頂層 Widget 按點 ( x , y );返迴 0 若沒有這種 Widget。
[static]
QWidgetList
QApplication::
topLevelWidgets
()
返迴應用程序頂層 Widget 窗口的列錶。
注意: 某些頂層 Widget 可能被隱藏 (例如:工具提示,若工具提示目前未展示)。
範例:
void showAllHiddenTopLevelWidgets() { foreach (QWidget *widget, QApplication::topLevelWidgets()) { if (widget->isHidden()) widget->show(); } }
另請參閱 allWidgets (), QWidget::isWindow (),和 QWidget::isHidden ().
[static]
Type
QApplication::
type
()
Returns the type of application ( Tty , GuiClient ,或 GuiServer ). The type is set when constructing the QApplication 對象。
[static]
QWidget
* QApplication::
widgetAt
(const
QPoint
&
point
)
返迴 Widget 按全局屏幕位置 point ,或 0 若那裏沒有 Qt Widget。
此函數可能很慢。
另請參閱 QCursor::pos (), QWidget::grabMouse (),和 QWidget::grabKeyboard ().
[static]
QWidget
* QApplication::
widgetAt
(
int
x
,
int
y
)
這是重載函數。
返迴 Widget 按全局屏幕位置 ( x , y ),或 0 若那裏沒有 Qt Widget。
[虛擬]
bool
QApplication::
x11EventFilter
(
XEvent
*
event
)
警告: This virtual function is only implemented under X11.
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. The events are passed in the event 參數。
Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false.
It is only the directly addressed messages that are filtered. You must install an event filter directly on the event dispatcher, which is returned by QAbstractEventDispatcher::instance (), to handle system wide messages.
另請參閱 x11ProcessEvent ().
This function does the core processing of individual X event s, normally by dispatching Qt events to the right destination.
It returns 1 if the event was consumed by special handling, 0 if the event was consumed by normal handling, and -1 if the event was for an unrecognized widget.
另請參閱 x11EventFilter ().
A global pointer referring to the unique application object. It is equivalent to the pointer returned by the QCoreApplication::instance () function except that, in GUI applications, it is a pointer to a QApplication 實例。
Only one application object can be created.
另請參閱 QCoreApplication::instance ().