<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # QCoreApplication Class Reference ## [[QtCore](index.htm) module] 該QCoreApplication類提供一個事件循環控制臺Qt應用程序。[More...](#details) 繼承[QObject](qobject.html)。 通過繼承[QApplication](qapplication.html)。 ### Types * `enum Encoding { CodecForTr, UnicodeUTF8, DefaultCodec }` ### Methods * `__init__ (self, list-of-str?argv)` * `bool event (self, QEvent)` * `bool notify (self, QObject, QEvent)` ### Static Methods * `addLibraryPath (QString)` * `QString applicationDirPath ()` * `QString applicationFilePath ()` * `QString applicationName ()` * `int applicationPid ()` * `QString applicationVersion ()` * `int argc ()` * `QStringList arguments ()` * `list-of-str argv ()` * `bool closingDown ()` * `int exec_ ()` * `exit (int?returnCode?=?0)` * `flush ()` * `bool hasPendingEvents ()` * `installTranslator (QTranslator)` * `QCoreApplication instance ()` * `QStringList libraryPaths ()` * `QString organizationDomain ()` * `QString organizationName ()` * `postEvent (QObject?receiver, QEvent?event)` * `postEvent (QObject?receiver, QEvent?event, int?priority)` * `processEvents (QEventLoop.ProcessEventsFlags?flags?=?QEventLoop.AllEvents)` * `processEvents (QEventLoop.ProcessEventsFlags?flags, int?maxtime)` * `quit ()` * `removeLibraryPath (QString)` * `removePostedEvents (QObject?receiver)` * `removePostedEvents (QObject?receiver, int?eventType)` * `removeTranslator (QTranslator)` * `bool sendEvent (QObject?receiver, QEvent?event)` * `sendPostedEvents (QObject?receiver, int?event_type)` * `sendPostedEvents ()` * `setApplicationName (QString?application)` * `setApplicationVersion (QString?version)` * `setAttribute (Qt.ApplicationAttribute?attribute, bool?on?=?True)` * `setLibraryPaths (QStringList)` * `setOrganizationDomain (QString?orgDomain)` * `setOrganizationName (QString?orgName)` * `bool startingUp ()` * `bool testAttribute (Qt.ApplicationAttribute?attribute)` * `QString translate (str?context, str?sourceText, str?disambiguation?=?None, Encoding?encoding?=?QCoreApplication.CodecForTr)` * `QString translate (str?context, str?sourceText, str?disambiguation, Encoding?encoding, int?n)` ### Qt Signals * `void aboutToQuit ()` * * * ## Detailed Description 該QCoreApplication類提供一個事件循環控制臺Qt應用程序。 這個類用于非GUI應用程序提供自己的事件循環。對于使用Qt的非GUI的應用程序,應該有只有一個QCoreApplication對象。對于GUI應用程序,請參見[QApplication](qapplication.html)。 QCoreApplication包含主事件循環,其中從操作系統(如定時器和網絡事件)和其他來源的所有事件被處理和調度。它也處理應用程序的初始化和結束,以及系統級和應用程序級設置。 ### The Event Loop and Event Handling 事件循環的開始調用[exec_](qcoreapplication.html#exec)( ) 。長時間運行的操作可以調用[processEvents](qcoreapplication.html#processEvents)( ),以保持應用程序的響應。 一般情況下,我們建議您創建一個QCoreApplication或[QApplication](qapplication.html)在你的對象`main()`功能盡可能早。[exec_](qcoreapplication.html#exec)( )將不會返回,直到事件循環退出,比如,當[quit](qcoreapplication.html#quit)()被調用。 還提供了一些靜態的便利功能。該QCoreApplication對象可從[instance](qcoreapplication.html#instance)( ) 。事件可以使用發送或張貼[sendEvent](qcoreapplication.html#sendEvent)( )[postEvent](qcoreapplication.html#postEvent)()和[sendPostedEvents](qcoreapplication.html#sendPostedEvents)( ) 。待處理的事件可以以去除[removePostedEvents](qcoreapplication.html#removePostedEvents)()或沖洗[flush](qcoreapplication.html#flush)( ) 。 這個類提供了一個[quit](qcoreapplication.html#quit)( )插槽和一個[aboutToQuit](qcoreapplication.html#aboutToQuit)()信號。 ### Application and Library Paths 一個應用程序有一個[applicationDirPath](qcoreapplication.html#applicationDirPath)()和一個[applicationFilePath](qcoreapplication.html#applicationFilePath)( ) 。庫路徑(見[QLibrary](qlibrary.html))可以檢索與[libraryPaths](qcoreapplication.html#libraryPaths)()和通過操縱[setLibraryPaths](qcoreapplication.html#setLibraryPaths)( )[addLibraryPath](qcoreapplication.html#addLibraryPath)()和[removeLibraryPath](qcoreapplication.html#removeLibraryPath)( ) 。 ### Internationalization and Translations 翻譯文件,可以添加或刪除使用[installTranslator](qcoreapplication.html#installTranslator)()和[removeTranslator](qcoreapplication.html#removeTranslator)( ) 。應用程序的字符串可以使用翻譯[translate](qcoreapplication.html#translate)( ) 。該[QObject.tr](qobject.html#tr)()和[QObject.trUtf8](qobject.html#trUtf8)( )函數在以下方面實施[translate](qcoreapplication.html#translate)( ) 。 ### Accessing Command Line Arguments 這是傳遞給QCoreApplication的構造函數中的命令行參數,應使用被訪問的[arguments](qcoreapplication.html#arguments)()函數。注意,由用戶提供某些參數可能已經被處理并通過QCoreApplication除去。 在情況下,命令行參數需要使用估計可得的[argv](index.htm#argv)( )函數,則必須使用本地字符串編碼將它們轉換[QString.fromLocal8Bit](qstring.html#fromLocal8Bit)( ) 。 ### Locale Settings 在Unix / Linux上的Qt配置默認使用系統區域設置。這可以使用時, POSIX函數,例如,數據類型,如浮點數和字符串之間進行轉換時引起沖突,因為符號的語言環境可能有所不同。為了解決這個問題,調用POSIX函數`setlocale(LC_NUMERIC,"C")`初始化之后[QApplication](qapplication.html)或QCoreApplication重置,用于數字格式為“C”語言環境的語言環境。 * * * ## Type Documentation ``` QCoreApplication.Encoding ``` 這個枚舉類型定義的字符串參數的8位編碼[translate](qcoreapplication.html#translate)(): | Constant | Value | Description | | --- | --- | --- | | `QCoreApplication.CodecForTr` | `0` | 由指定的編碼[QTextCodec.codecForTr](qtextcodec.html#codecForTr)( ) ( Latin-1的,如果沒有設置) 。 | | `QCoreApplication.UnicodeUTF8` | `1` | UTF - 8 。 | | `QCoreApplication.DefaultCodec` | `CodecForTr` | (過時)使用CodecForTr代替。 | **See also** [QObject.tr](qobject.html#tr)( )[QObject.trUtf8](qobject.html#trUtf8)()和[QString.fromUtf8](qstring.html#fromUtf8)( ) 。 * * * ## Method Documentation ``` QCoreApplication.__init__ (self, list-of-str?argv) ``` 構造一個內核的Qt應用程序。核心應用是沒有圖形用戶界面應用程序。這些類型的應用程序用于在控制臺或服務器進程。 該_argc_和_argv_參數由應用程序進行處理,并通過在一個更方便的形式提供[arguments](qcoreapplication.html#arguments)()函數。 **Warning:**由所述資料_argc_和_argv_必須保持有效的整個生命周期[QCoreApplication](qcoreapplication.html)對象。另外,_argc_必須大于零和_argv_必須至少包含一個有效的字符串。 ``` QCoreApplication.addLibraryPath (QString) ``` 預先考慮_path_到庫路徑列表,以確保它是搜索庫首的開始。如果_path_是空的,或者已經在路徑列表中的路徑列表中不被改變。 默認路徑列表包含一個條目,用于插件的安裝目錄。對于插件的默認安裝目錄為`INSTALL/plugins`,其中`INSTALL`在這里安裝Qt的目錄。 在Symbian此功能僅適用于添加路徑查找Qt的擴展插件存根有用的,因為從操作系統只能加載庫`/sys/bin`目錄。 **See also** [removeLibraryPath](qcoreapplication.html#removeLibraryPath)( )[libraryPaths](qcoreapplication.html#libraryPaths)()和[setLibraryPaths](qcoreapplication.html#setLibraryPaths)( ) 。 ``` QString QCoreApplication.applicationDirPath () ``` 返回包含應用程序的可執行文件的目錄。 例如,如果您在安裝的Qt`C:\Trolltech\Qt`目錄,并運行`regexp`例如,此函數將返回“C :/奇趣/ QT /例子/工具/正則表達式” 。 在Mac OS X ,這將指向實際上包含可執行文件的目錄,這可能是一個應用程序包(如果應用程序捆綁)內。 **Warning:**在Linux上,此功能將嘗試從一開始的路徑`/proc`文件系統。如果失敗,它假定`argv[0]`包含可執行文件的絕對文件名。該功能還假定當前目錄沒有被應用程序修改。 在Symbian這個函數將返回該應用程序私有目錄,而不是路徑到可執行文件本身,那些總是在`/sys/bin`。如果應用程序是在一個只讀驅動器,即光盤,然后在系統驅動器上的專用路徑將被退回。 **See also** [applicationFilePath](qcoreapplication.html#applicationFilePath)( ) 。 ``` QString QCoreApplication.applicationFilePath () ``` 返回應用程序的可執行文件的文件路徑。 例如,如果您在安裝的Qt`/usr/local/qt`目錄,并運行`regexp`例如,此函數將返回“的/ usr /本地/ QT /例子/工具/正則表達式/正則表達式” 。 **Warning:**在Linux上,此功能將嘗試從一開始的路徑`/proc`文件系統。如果失敗,它假定`argv[0]`包含可執行文件的絕對文件名。該功能還假定當前目錄沒有被應用程序修改。 **See also** [applicationDirPath](qcoreapplication.html#applicationDirPath)( ) 。 ``` QString QCoreApplication.applicationName () ``` ``` int QCoreApplication.applicationPid () ``` 返回當前進程的ID為應用。 此功能被引入Qt的4.4 。 ``` QString QCoreApplication.applicationVersion () ``` ``` int QCoreApplication.argc () ``` ``` QStringList QCoreApplication.arguments () ``` 返回的命令行參數列表。 通常參數( ),在( 0 )是程序名稱,參數( ),在( 1)的第一個參數,并且參數( ) ,最后( )是最后一個參數。見下面的注釋關于Windows 。 調用此函數是緩慢的 - 你應該在解析命令行的時候將結果存儲在變量中。 **Warning:**在Unix中,這個名單是從傳遞給構造函數在main( )函數的argc和argv參數建成。 argv中的字符串數據是使用解釋[QString.fromLocal8Bit](qstring.html#fromLocal8Bit)( ) ,因此它是不可能通過,例如,日本的命令行參數運行在拉丁文的語言環境的系統上。大多數現代的Unix系統沒有這個限制,因為它們是基于Unicode的。 在基于NT的Windows中,這一限制并不適用于任。在Windows中, ()的參數不是從ARGV / ARGC的內容建成,作為內容不支持Unicode 。相反, ()的參數是從的返回值構造[GetCommandLine()](http://msdn2.microsoft.com/en-us/library/ms683156(VS.85).aspx)。作為這樣的結果, )由參數(給定的字符串。在(0)可能沒有在Windows程序名稱,這取決于應用程序的啟動方式。 對于Symbian應用程序開始`RApaLsSession.StartApp`可以使用指定的參數`CApaCommandLine.SetTailEndL`功能。這種論調只能通過這種方法,他們將不會被傳遞到`main`功能。另外請注意,與只設置8位字符串數據`CApaCommandLine.SetTailEndL`此函數支持。 這個函數是Qt 4.1中引入。 **See also** [applicationFilePath](qcoreapplication.html#applicationFilePath)( ) 。 ``` list-of-str QCoreApplication.argv () ``` ``` bool QCoreApplication.closingDown () ``` 返回如果應用程序對象被銷毀True,否則返回False 。 **See also** [startingUp](qcoreapplication.html#startingUp)( ) 。 ``` bool QCoreApplication.event (self, QEvent) ``` 從重新實現[QObject.event](qobject.html#event)( ) 。 ``` int QCoreApplication.exec_ () ``` 進入主事件循環并等待,直到[exit](qcoreapplication.html#exit)()被調用。返回被設置為值[exit](qcoreapplication.html#exit)()(它是0,如果[exit](qcoreapplication.html#exit)( )通過調用[quit](qcoreapplication.html#quit)())。 有必要調用這個函數來啟動事件處理。主事件循環接收事件從窗口系統并調度這些應用程序的部件。 為了使您的應用程序執行閒置處理(即執行一個特殊的功能,每當有沒有掛起的事件) ,請使用[QTimer](qtimer.html)與0超時。更高級的空閒處理方案可以用來實現[processEvents](qcoreapplication.html#processEvents)( ) 。 我們建議您清理代碼連接到[aboutToQuit()](qcoreapplication.html#aboutToQuit)信號,而不是把它在你的應用程序,`main()`函數,因為在某些平臺上的QCoreApplication.exec ( )調用可能不會返回。例如,在Windows上,當用戶注銷時,系統終止進程的Qt關閉所有頂層窗口之后。因此,也不能保證該應用程序將有時間退出事件循環,并執行代碼的結束`main()`該QCoreApplication.exec ( )調用后的功能。 **See also** [quit](qcoreapplication.html#quit)( )[exit](qcoreapplication.html#exit)( )[processEvents](qcoreapplication.html#processEvents)()和[QApplication.exec](qapplication.html#exec)( ) 。 ``` QCoreApplication.exit (int?returnCode?=?0) ``` 告訴應用程序退出,并返回代碼。 在此之后函數被調用,應用程序離開主事件循環,并從調用返回[exec_](qcoreapplication.html#exec)( ) 。該[exec_](qcoreapplication.html#exec)( )函數返回_returnCode_。如果事件循環沒有運行,這個函數不執行任何操作。 按照慣例,_returnCode_0意味著成功,而任何非零值表示錯誤。 請注意,與同名的C庫函數,這個函數_does_返回給調用者 - 它是事件處理,停止。 **See also** [quit](qcoreapplication.html#quit)()和[exec_](qcoreapplication.html#exec)( ) 。 ``` QCoreApplication.flush () ``` 刷新特定于平臺的事件隊列。 如果你正在做一個循環中的圖形的變化,不返回到異步窗口系統,例如X11或者雙緩沖窗口系統,例如Mac OS X中的事件循環,并要立即顯現這些變化(如閃屏) ,調用這個函數。 **See also** [sendPostedEvents](qcoreapplication.html#sendPostedEvents)( ) 。 ``` bool QCoreApplication.hasPendingEvents () ``` 如果有未完成的事件這個函數返回True,否則返回False 。掛起的事件可以是從窗口系統或使用posted事件[postEvent](qcoreapplication.html#postEvent)( ) 。 **See also** [QAbstractEventDispatcher.hasPendingEvents](qabstracteventdispatcher.html#hasPendingEvents)( ) 。 ``` QCoreApplication.installTranslator (QTranslator) ``` 添加翻譯文件_translationFile_到的翻譯文件以用于翻譯的列表。 多重翻譯文件安裝即可。翻譯是在它們被安裝在其相反的順序搜索的,所以最近安裝的翻譯文件首先搜索并安裝了第一個翻譯文件最后搜索。搜索一旦被發現包含匹配的字符串翻譯停止。 安裝或拆卸[QTranslator](qtranslator.html)或改變已安裝的[QTranslator](qtranslator.html)生成一個[LanguageChange](qevent.html#Type-enum)事件為[QCoreApplication](qcoreapplication.html)實例。一[QApplication](qapplication.html)例如將傳播事件給所有頂層窗口,其中changeEvent中的一個重新實現可以通過通過通過用戶可見的字符串重新翻譯的用戶界面[tr](qobject.html#tr)( )函數將相應的屬性setter方法??。通過生成用戶界面的類[Qt Designer](index.htm#qt-designer)提供`retranslateUi()`函數可以被調用。 **See also** [removeTranslator](qcoreapplication.html#removeTranslator)( )[translate](qcoreapplication.html#translate)( )[QTranslator.load](qtranslator.html#load)()和[Dynamic Translation](index.htm#dynamic-translation)。 ``` QCoreApplication QCoreApplication.instance () ``` [](qcoreapplication.html) [返回一個指向應用程序的](qcoreapplication.html)[QCoreApplication](qcoreapplication.html)(或[QApplication](qapplication.html))實例。 如果沒有實例已分配,`null`返回。 ``` QStringList QCoreApplication.libraryPaths () ``` 返回該應用程序將搜索時動態加載庫的路徑列表。 Qt提供了默認的庫路徑,但它們也可以使用設置[qt.conf](index.htm)文件中。在該文件中指定的路徑將復蓋默認值。 如果存在的話(對于插件的默認安裝目錄是這份名單將包括插件的安裝目錄`INSTALL/plugins`,其中`INSTALL`在這里安裝Qt的目錄) 。該應用程序的可執行文件(而不是工作目錄)的目錄總是被添加,以及冒號分隔的QT_PLUGIN_PATH環境變量的條目。 如果你想遍歷列表中,您可以使用[foreach](index.htm#foreach)偽關鍵字: ``` foreach (const [QString](qstring.html) &path, app.libraryPaths()) do_something(path); ``` **See also** [setLibraryPaths](qcoreapplication.html#setLibraryPaths)( )[addLibraryPath](qcoreapplication.html#addLibraryPath)( )[removeLibraryPath](qcoreapplication.html#removeLibraryPath)( )[QLibrary](qlibrary.html)和[How to Create Qt Plugins](index.htm)。 ``` bool QCoreApplication.notify (self, QObject, QEvent) ``` 發送_event_至_receiver_:_receiver_ - \u003e事件(_event_) 。返回從接收器的事件處理程序中返回的值。注意,該函數用于在任何線程中發送到任何對象的所有事件。 對于某些類型的事件(例如鼠標和鍵盤事件) ,事件將被傳播到接收器的父,所以一直到頂層對象,如果接收器是不感興趣的事件(即,它返回False ) 。 有跡象表明,事件可以被處理五種不同的方法;重新實現該虛擬函數只是其中之一。所有五個途徑如下: 1. 重新實現的paintEvent () , mousePressEvent ()等等。這是最常見,最簡單,最有力的方式。 2. 重新實現此功能。這是非常強大,提供了完整的控制,但只有一個子類可以同時處于活動狀態。 3. 上安裝一個事件過濾器[QCoreApplication.instance](qcoreapplication.html#instance)( ) 。這樣的事件過濾器能夠處理所有部件的所有事件,所以它只是一樣強大的重新實現notify()方法,此外,它可能有一個以上的應用程序全局事件過濾器。全局事件過濾器甚至可以看到鼠標事件[disabled widgets](qwidget.html#enabled-prop)。請注意,應用程序事件過濾器只要求居住在主線程中的對象。 4. 重新實現[QObject.event](qobject.html#event)( ) (如[QWidget](qwidget.html)一樣) 。如果你這樣做你會得到Tab鍵按下,你會得到之前的任何部件特定的事件篩選器查看的事件。 5. 在對象上安裝事件過濾器。這樣的事件過濾器得到所有的活動,包括Tab鍵和Shift + Tab鍵的按鍵事件,只要他們不改變的重點部件。 **See also** [QObject.event](qobject.html#event)()和[installEventFilter](qobject.html#installEventFilter)( ) 。 ``` QString QCoreApplication.organizationDomain () ``` ``` QString QCoreApplication.organizationName () ``` ``` QCoreApplication.postEvent (QObject?receiver, QEvent?event) ``` 該_event_說法有它的所有權轉移給Qt的。 添加事件_event_,與對象_receiver_作為該事件的接收器,立刻事件隊列并返回。 該事件必須被分配在堆上,因為后期的事件隊列會借此事件的所有權,并刪除它一旦被發布。這是_not safe_訪問事件已張貼后。 當控制返回到主事件循環,存儲在隊列中的所有事件將要使用的發送[notify](qcoreapplication.html#notify)()函數。 事件在張貼的順序處理。為了更好地控制處理順序,使用下面的postEvent ()重載,它接受一個優先級參數。這個函數的職位的所有事件與[Qt.NormalEventPriority](qt.html#EventPriority-enum)。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [sendEvent](qcoreapplication.html#sendEvent)( )[notify](qcoreapplication.html#notify)()和[sendPostedEvents](qcoreapplication.html#sendPostedEvents)( ) 。 ``` QCoreApplication.postEvent (QObject?receiver, QEvent?event, int?priority) ``` 該_event_說法有它的所有權轉移給Qt的。 這個函數的重載[postEvent](qcoreapplication.html#postEvent)( ) 。 添加事件_event_,與對象_receiver_作為該事件的接收器,立刻事件隊列并返回。 該事件必須被分配在堆上,因為后期的事件隊列會借此事件的所有權,并刪除它一旦被發布。這是_not safe_訪問事件已張貼后。 當控制返回到主事件循環,存儲在隊列中的所有事件將要使用的發送[notify](qcoreapplication.html#notify)()函數。 活動按降序_priority_秩序,即事件的高_priority_具有較低的事件之前排隊_priority_。該_priority_可以是任意整數值,即INT_MAX和INT_MIN (含)之間,見[Qt.EventPriority](qt.html#EventPriority-enum)更多的細節。以同樣的活動_priority_將發布的順序進行處理。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 此功能被引入Qt的4.3 。 **See also** [sendEvent](qcoreapplication.html#sendEvent)( )[notify](qcoreapplication.html#notify)( )[sendPostedEvents](qcoreapplication.html#sendPostedEvents)()和[Qt.EventPriority](qt.html#EventPriority-enum)。 ``` QCoreApplication.processEvents (QEventLoop.ProcessEventsFlags?flags?=?QEventLoop.AllEvents) ``` 流程根據指定的調用線程的所有等待事件_flags_直到有沒有更多的事件來處理。 你可以偶爾調用此函數時,你的程序是忙于執行一個長時間的操作(例如,復制文件) 。 在事件中,你正在運行一個本地環路的不斷調用這個函數,沒有一個事件循環,[DeferredDelete](qevent.html#Type-enum)事件將不會被處理。這可能會影響部件的性能,例如[QToolTip](qtooltip.html),依賴于[DeferredDelete](qevent.html#Type-enum)事件才能正常工作。另一種方法是調用[sendPostedEvents()](qcoreapplication.html#sendPostedEvents)從內本地環路。 調用此功能僅適用于調用線程處理事件。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [exec_](qcoreapplication.html#exec)( )[QTimer](qtimer.html),[QEventLoop.processEvents](qeventloop.html#processEvents)( )[flush](qcoreapplication.html#flush)()和[sendPostedEvents](qcoreapplication.html#sendPostedEvents)( ) 。 ``` QCoreApplication.processEvents (QEventLoop.ProcessEventsFlags?flags, int?maxtime) ``` 這個函數的重載[processEvents](qcoreapplication.html#processEvents)( ) 。 為調用線程的進程掛起的事件_maxtime_毫秒,直到沒有更多的事件來處理,以較短者為準。 你可以偶爾調用此函數時,你的程序是忙著做一個長時間的操作(例如,復制文件) 。 調用此功能僅適用于調用線程處理事件。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [exec_](qcoreapplication.html#exec)( )[QTimer](qtimer.html)和[QEventLoop.processEvents](qeventloop.html#processEvents)( ) 。 ``` QCoreApplication.quit () ``` 這種方法也是一個Qt槽與C + +的簽名`void quit()`。 告訴應用程序退出,返回代碼為0(成功) 。等效于調用QCoreApplication.exit ( 0 ) 。 這是常見的連接[QApplication.lastWindowClosed](qapplication.html#lastWindowClosed)( )信號退出( ) ,你也經常連接如[QAbstractButton.clicked](qabstractbutton.html#clicked)()或信號[QAction](qaction.html),[QMenu](qmenu.html)或[QMenuBar](qmenubar.html)到它。 例如: ``` [QPushButton](qpushbutton.html) *quitButton = new [QPushButton](qpushbutton.html)("Quit"); connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit())); ``` **See also** [exit](qcoreapplication.html#exit)( )[aboutToQuit](qcoreapplication.html#aboutToQuit)()和[QApplication.lastWindowClosed](qapplication.html#lastWindowClosed)( ) 。 ``` QCoreApplication.removeLibraryPath (QString) ``` 移除_path_從庫路徑列表。如果_path_為空或不是路徑列表中,該列表不會改變。 **See also** [addLibraryPath](qcoreapplication.html#addLibraryPath)( )[libraryPaths](qcoreapplication.html#libraryPaths)()和[setLibraryPaths](qcoreapplication.html#setLibraryPaths)( ) 。 ``` QCoreApplication.removePostedEvents (QObject?receiver) ``` 刪除所有的事件發表使用[postEvent](qcoreapplication.html#postEvent)( )為_receiver_。 該事件是_not_出動,而是被從隊列中刪除。你不應該需要調用這個函數。如果你調用它,要知道,殺事件可能造成_receiver_打破一個或多個變量。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 ``` QCoreApplication.removePostedEvents (QObject?receiver, int?eventType) ``` 這個函數的重載[removePostedEvents](qcoreapplication.html#removePostedEvents)( ) 。 刪除給定的所有事件_eventType_這是用貼[postEvent](qcoreapplication.html#postEvent)( )為_receiver_。 該事件是_not_出動,而是被從隊列中刪除。你不應該需要調用這個函數。如果你調用它,要知道,殺事件可能造成_receiver_打破一個或多個變量。 If _receiver_為null ,發生的事件_eventType_被刪除的所有對象。如果_eventType_為0 ,所有的事件都將被刪除_receiver_。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 此功能被引入Qt的4.3 。 ``` QCoreApplication.removeTranslator (QTranslator) ``` 刪除的文件翻譯_translationFile_從該應用程序使用翻譯文件的列表。 (它不會從文件系統中刪除翻譯文件。 ) **See also** [installTranslator](qcoreapplication.html#installTranslator)( )[translate](qcoreapplication.html#translate)()和[QObject.tr](qobject.html#tr)( ) 。 ``` bool QCoreApplication.sendEvent (QObject?receiver, QEvent?event) ``` 發送事件_event_直接到接收器_receiver_使用[notify](qcoreapplication.html#notify)()函數。返回從事件處理程序返回的值。 本次活動是_not_當事件已發送刪除。正常的方法是創建事件的堆棧,例如: ``` [QMouseEvent](qmouseevent.html) event([QEvent](qevent.html).MouseButtonPress, pos, 0, 0, 0); [QApplication](qapplication.html).sendEvent(mainWindow, &event); ``` **See also** [postEvent](qcoreapplication.html#postEvent)()和[notify](qcoreapplication.html#notify)( ) 。 ``` QCoreApplication.sendPostedEvents (QObject?receiver, int?event_type) ``` 立即調度已與以前排隊的所有事件[QCoreApplication.postEvent](qcoreapplication.html#postEvent)()和它們的對象_receiver_和具有事件類型_event_type_。 從窗口系統事件_not_通過此功能布控,而是由[processEvents](qcoreapplication.html#processEvents)( ) 。 If _receiver_為null ,發生的事件_event_type_被發送的所有對象。如果_event_type_是0 ,所有的事件都被發送給_receiver_。 **Note:**此方法必須從同一個線程中調用它[QObject](qobject.html)參數,_receiver_。 **See also** [flush](qcoreapplication.html#flush)()和[postEvent](qcoreapplication.html#postEvent)( ) 。 ``` QCoreApplication.sendPostedEvents () ``` 這個函數的重載[sendPostedEvents](qcoreapplication.html#sendPostedEvents)( ) 。 調度所有的posted事件,即清空事件隊列。 ``` QCoreApplication.setApplicationName (QString?application) ``` ``` QCoreApplication.setApplicationVersion (QString?version) ``` ``` QCoreApplication.setAttribute (Qt.ApplicationAttribute?attribute, bool?on?=?True) ``` 設置屬性_attribute_如果_on_為True,否則清除該屬性。 之一,可以用這種方法來設置的屬性是[Qt.AA_ImmediateWidgetCreation](qt.html#ApplicationAttribute-enum)。它告訴Qt立即創建頂層窗口。通常情況下,對于小部件的資源按需分配,提高效率,減少資源的使用。因此,如果要最大限度地減少資源消耗是很重要的,不要設置此屬性。 **See also** [testAttribute](qcoreapplication.html#testAttribute)( ) 。 ``` QCoreApplication.setLibraryPaths (QStringList) ``` 設置目錄列表加載庫時要搜索_paths_。所有現有的路徑將被刪除,路徑列表將包含在給定路徑_paths_。 在Symbian此功能僅用于設置路徑查找Qt的擴展插件存根有用的,因為從操作系統只能加載庫`/sys/bin`目錄。 **See also** [libraryPaths](qcoreapplication.html#libraryPaths)( )[addLibraryPath](qcoreapplication.html#addLibraryPath)( )[removeLibraryPath](qcoreapplication.html#removeLibraryPath)()和[QLibrary](qlibrary.html)。 ``` QCoreApplication.setOrganizationDomain (QString?orgDomain) ``` ``` QCoreApplication.setOrganizationName (QString?orgName) ``` ``` bool QCoreApplication.startingUp () ``` 如果一個應用程序對象尚未創建,則返回True ,否則返回False 。 **See also** [closingDown](qcoreapplication.html#closingDown)(). ``` bool QCoreApplication.testAttribute (Qt.ApplicationAttribute?attribute) ``` 返回True ,如果屬性_attribute_被置位,否則返回False 。 **See also** [setAttribute](qcoreapplication.html#setAttribute)( ) 。 ``` QString QCoreApplication.translate (str?context, str?sourceText, str?disambiguation?=?None, Encoding?encoding?=?QCoreApplication.CodecForTr) ``` 返回翻譯文本_sourceText_,通過查詢已安裝的翻譯文件。翻譯文件中搜索從最近安裝的文件恢復到第一次安裝文件。 [QObject.tr](qobject.html#tr)()和[QObject.trUtf8](qobject.html#trUtf8)( )更方便地提供了這種功能。 _context_通常是一個類名稱(例如,“程序MyDialog ” )和_sourceText_要么是英文的文字或短識別文字。 _disambiguation_是一個識別字符串,當相同的_sourceText_采用的是同一個范圍內不同的角色。默認情況下,它是空的。 請參閱[QTranslator](qtranslator.html)和[QObject.tr](qobject.html#tr)( )文檔以了解有關背景, disambiguations和注釋的詳細信息。 _encoding_表示字符串的8位編碼。 _n_用于與結合`%n`支持復數形式。看[QObject.tr](qobject.html#tr)( )了解詳情。 如果沒有翻譯文件中包含了翻譯_sourceText_在_context_,這個函數返回一個[QString](qstring.html)相當于_sourceText_。的編碼_sourceText_通過指定_encoding_它默認為[CodecForTr](qcoreapplication.html#Encoding-enum)。 這個函數是不是虛擬的。你可以通過繼承使用其他翻譯技巧[QTranslator](qtranslator.html)。 **Warning:**這種方法是可重入只有在安裝了所有的翻譯_before_調用此方法。但不支持進行翻譯安裝或刪除翻譯。這樣做很可能會導致崩潰或其他不良行為。 **Note:**這個功能是[reentrant](index.htm#reentrant)。 此功能被引入Qt的4.5 。 **See also** [QObject.tr](qobject.html#tr)( )[installTranslator](qcoreapplication.html#installTranslator)()和[QTextCodec.codecForTr](qtextcodec.html#codecForTr)( ) 。 ``` QString QCoreApplication.translate (str?context, str?sourceText, str?disambiguation, Encoding?encoding, int?n) ``` 這個函數的重載[translate](qcoreapplication.html#translate)( ) 。 * * * ## Qt Signal Documentation ``` void aboutToQuit () ``` 這是該信號的默認超載。 當應用程序即將退出主事件循環,比如這個信號被發射當事件循環水平下降到零。要么在調用這可能發生[quit](qcoreapplication.html#quit)( )從內部的應用程序,或當用戶關閉整個桌面會話。 如果你的應用程序需要做一些最后一秒清理的信號特別有用。請注意,沒有用戶交互可能處于這種狀態。 **See also** [quit](qcoreapplication.html#quit)( ) 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看