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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # QObject Class Reference ## [[QtCore](index.htm) module] 該QObject的類是所有的Qt對象的基類。[More...](#details) 通過繼承[AbstractAudioOutput](index.htm),[Notifier](index.htm),[Effect](index.htm),[MediaController](index.htm),[MediaObject](index.htm),[QAbstractAnimation](qabstractanimation.html),[QAbstractEventDispatcher](qabstracteventdispatcher.html),[QAbstractItemDelegate](qabstractitemdelegate.html),[QAbstractItemModel](qabstractitemmodel.html),[QAbstractMessageHandler](qabstractmessagehandler.html),[QAbstractNetworkCache](qabstractnetworkcache.html),[QAbstractState](qabstractstate.html),[QAbstractTextDocumentLayout](qabstracttextdocumentlayout.html),[QAbstractTransition](qabstracttransition.html),[QAbstractUriResolver](qabstracturiresolver.html),[QAbstractVideoSurface](qabstractvideosurface.html),[QAction](qaction.html),[QActionGroup](qactiongroup.html),[QAssistantClient](qassistantclient.html),[QAudioInput](qaudioinput.html),[QAudioOutput](qaudiooutput.html),[QButtonGroup](qbuttongroup.html),[QClipboard](qclipboard.html),[QCompleter](qcompleter.html),[QCoreApplication](qcoreapplication.html),[QDataWidgetMapper](qdatawidgetmapper.html),[QDBusAbstractAdaptor](qdbusabstractadaptor.html),[QDBusAbstractInterface](qdbusabstractinterface.html),[QDBusPendingCallWatcher](qdbuspendingcallwatcher.html),[QDBusServiceWatcher](qdbusservicewatcher.html),[QDeclarativeComponent](qdeclarativecomponent.html),[QDeclarativeContext](qdeclarativecontext.html),[QDeclarativeEngine](qdeclarativeengine.html),[QDeclarativeExpression](qdeclarativeexpression.html),[QDeclarativeExtensionPlugin](qdeclarativeextensionplugin.html),[QDeclarativePropertyMap](qdeclarativepropertymap.html),[QDesignerFormEditorInterface](qdesignerformeditorinterface.html),[QDesignerFormWindowManagerInterface](qdesignerformwindowmanagerinterface.html),[QDrag](qdrag.html),[QEventLoop](qeventloop.html),[QExtensionFactory](qextensionfactory.html),[QExtensionManager](qextensionmanager.html),[QFileSystemWatcher](qfilesystemwatcher.html),[QFtp](qftp.html),[QGesture](qgesture.html),[QGLShader](qglshader.html),[QGLShaderProgram](qglshaderprogram.html),[QGraphicsAnchor](qgraphicsanchor.html),[QGraphicsEffect](qgraphicseffect.html),[QGraphicsItemAnimation](qgraphicsitemanimation.html),[QGraphicsObject](qgraphicsobject.html),[QGraphicsScene](qgraphicsscene.html),[QGraphicsTransform](qgraphicstransform.html),[QHelpEngineCore](qhelpenginecore.html),[QHelpSearchEngine](qhelpsearchengine.html),[QHttp](qhttp.html),[QHttpMultiPart](qhttpmultipart.html),[QInputContext](qinputcontext.html),[QIODevice](qiodevice.html),[QItemSelectionModel](qitemselectionmodel.html),[QLayout](qlayout.html),[QLibrary](qlibrary.html),[QLocalServer](qlocalserver.html),[QMimeData](qmimedata.html),[QMovie](qmovie.html),[QNetworkAccessManager](qnetworkaccessmanager.html),[QNetworkConfigurationManager](qnetworkconfigurationmanager.html),[QNetworkCookieJar](qnetworkcookiejar.html),[QNetworkSession](qnetworksession.html),[QObjectCleanupHandler](qobjectcleanuphandler.html),[QPluginLoader](qpluginloader.html),[QPyDeclarativePropertyValueSource](qpydeclarativepropertyvaluesource.html),[QPyDesignerContainerExtension](qpydesignercontainerextension.html),[QPyDesignerCustomWidgetCollectionPlugin](qpydesignercustomwidgetcollectionplugin.html),[QPyDesignerCustomWidgetPlugin](qpydesignercustomwidgetplugin.html),[QPyDesignerMemberSheetExtension](qpydesignermembersheetextension.html),[QPyDesignerPropertySheetExtension](qpydesignerpropertysheetextension.html),[QPyDesignerTaskMenuExtension](qpydesignertaskmenuextension.html),[QPyTextObject](qpytextobject.html),[QScriptEngine](qscriptengine.html),[QScriptEngineDebugger](qscriptenginedebugger.html),[QSessionManager](qsessionmanager.html),[QSettings](qsettings.html),[QSharedMemory](qsharedmemory.html),[QShortcut](qshortcut.html),[QSignalMapper](qsignalmapper.html),[QSocketNotifier](qsocketnotifier.html),[QSound](qsound.html),[QSqlDriver](qsqldriver.html),[QStyle](qstyle.html),[QSvgRenderer](qsvgrenderer.html),[QSyntaxHighlighter](qsyntaxhighlighter.html),[QSystemTrayIcon](qsystemtrayicon.html),[QTcpServer](qtcpserver.html),[QTextDocument](qtextdocument.html),[QTextObject](qtextobject.html),[QThread](qthread.html),[QThreadPool](qthreadpool.html),[QTimeLine](qtimeline.html),[QTimer](qtimer.html),[QTranslator](qtranslator.html),[QUndoGroup](qundogroup.html),[QUndoStack](qundostack.html),[QValidator](qvalidator.html),[QWebFrame](qwebframe.html),[QWebHistoryInterface](qwebhistoryinterface.html),[QWebPage](qwebpage.html),[QWebPluginFactory](qwebpluginfactory.html)和[QWidget](qwidget.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `bool blockSignals (self, bool?b)` * `childEvent (self, QChildEvent)` * `list-of-QObject children (self)` * `bool connect (self, QObject, SIGNAL(), SLOT(), Qt.ConnectionType?=?Qt.AutoConnection)` * `connectNotify (self, SIGNAL()?signal)` * `customEvent (self, QEvent)` * `deleteLater (self)` * `disconnectNotify (self, SIGNAL()?signal)` * `dumpObjectInfo (self)` * `dumpObjectTree (self)` * `list-of-QByteArray dynamicPropertyNames (self)` * `emit (self, SIGNAL(), ...)` * `bool event (self, QEvent)` * `bool eventFilter (self, QObject, QEvent)` * `QObject findChild (self, type?type, QString?name?=?QString())` * `QObject findChild (self, tuple?types, QString?name?=?QString())` * `list-of-QObject findChildren (self, type?type, QString?name?=?QString())` * `list-of-QObject findChildren (self, tuple?types, QString?name?=?QString())` * `list-of-QObject findChildren (self, type?type, QRegExp?regExp)` * `list-of-QObject findChildren (self, tuple?types, QRegExp?regExp)` * `bool inherits (self, str?classname)` * `installEventFilter (self, QObject)` * `bool isWidgetType (self)` * `killTimer (self, int?id)` * `QMetaObject metaObject (self)` * `moveToThread (self, QThread?thread)` * `QString objectName (self)` * `QObject parent (self)` * `QVariant property (self, str?name)` * `pyqtConfigure (self, object)` * `int receivers (self, SIGNAL()?signal)` * `removeEventFilter (self, QObject)` * `QObject sender (self)` * `int senderSignalIndex (self)` * `setObjectName (self, QString?name)` * `setParent (self, QObject)` * `bool setProperty (self, str?name, QVariant?value)` * `bool signalsBlocked (self)` * `int startTimer (self, int?interval)` * `QThread thread (self)` * `timerEvent (self, QTimerEvent)` * `QString tr (self, str?sourceText, str?disambiguation?=?None, int?n?=?-1)` * `QString trUtf8 (self, str?sourceText, str?disambiguation?=?None, int?n?=?-1)` ### Static Methods * `bool connect (QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType?=?Qt.AutoConnection)` * `bool connect (QObject, SIGNAL(), callable, Qt.ConnectionType?=?Qt.AutoConnection)` * `bool disconnect (QObject, SIGNAL(), QObject, SLOT())` * `bool disconnect (QObject, SIGNAL(), callable)` ### Special Methods * `object __getattr__ (self, str?name)` ### Qt Signals * `void destroyed (QObject * = 0)` ### Static Members * `QMetaObject **[staticMetaObject](qobject.html#staticMetaObject-var)**` * * * ## Detailed Description 該QObject的類是所有的Qt對象的基類。 QObject的是Qt的心臟[Object Model](index.htm)。在此模型中的核心特征是一種稱為非常強大的機制來無縫對象的通信[signals and slots](index.htm#signals-and-slots)。你可以用一個信號連接到槽[connect](qobject.html#connect)( )和destroy與連接[disconnect](qobject.html#disconnect)( ) 。為了避免無休止的通知循環可以暫時阻止信號與[blockSignals](qobject.html#blockSignals)( ) 。該保護功能[connectNotify](qobject.html#connectNotify)()和[disconnectNotify](qobject.html#disconnectNotify)()使得有可能跟蹤的連接。 [QObjects](index.htm#qobjects)組織起來的[object trees](index.htm)。當你創建與另一個對象作為父項的QObject的,該對象將自己自動添加到父的[children](qobject.html#children)( )列表。家長需要的對象的所有權,也就是說,它會自動刪除其在其析構函數的孩子。你可以找一個對象的名字和可選輸入使用[findChild](qobject.html#findChild)()或[findChildren](qobject.html#findChildren)( ) 。 每個對象都有一個[objectName](qobject.html#objectName-prop)( )和它的類名可以通過相應的發現[metaObject](qobject.html#metaObject)( ) (見[QMetaObject.className](qmetaobject.html#className)())。你能確定對象的類是否繼承另一個類中的QObject繼承層次結構使用[inherits](qobject.html#inherits)()函數。 當一個對象被刪除時,它會發出一個[destroyed](qobject.html#destroyed)()信號。你可以捕獲這個信號,以避免懸空引用[QObjects](index.htm#qobjects)。 [QObjects](index.htm#qobjects)可以通過接收事件[event](qobject.html#event)()和過濾器的其他對象的事件。看[installEventFilter](qobject.html#installEventFilter)()和[eventFilter](qobject.html#eventFilter)( )了解詳情。一個方便的處理程序,[childEvent](qobject.html#childEvent)( ) ,可重新實現以趕上孩子的事件。 事件被交付于該對象被創建的線程,見[Thread Support in Qt](index.htm)和[thread](qobject.html#thread)( )了解詳情。請注意,事件處理是根本無法完成的[QObjects](index.htm#qobjects)沒有線程關聯([thread](qobject.html#thread)( )返回零) 。使用[moveToThread](qobject.html#moveToThread)( )函數來改變一個對象及其子對象的線程關聯(如果它有一個父對象不能移動) 。 最后但并非最不重要的, QObject中提供了Qt的基本定時器支持;見[QTimer](qtimer.html)為定時器高層的支持。 請注意,該[Q_OBJECT](qobject.html#Q_OBJECT)宏是強制實現信號,槽或屬性的對象。您還需要運行[Meta Object Compiler](index.htm#moc)在源文件中。我們強烈建議使用這個宏的QObject的子類,而不管是否與自己實際使用的信號,槽和屬性,因為如果不這樣做可能會導致某些功能表現出奇怪的行為。 Qt的所有控件繼承QObject的。便利的功能[isWidgetType](qobject.html#isWidgetType)( )返回一個對象是否實際上是一個小部件。這是比要快得多[qobject_cast](qobject.html#qobject_cast)\u003c[QWidget](qwidget.html)* \u003e (_obj_)或_obj_ - \u003e[inherits](qobject.html#inherits)( “[QWidget](qwidget.html)“ ) 。 一些QObject的功能,例如[children](qobject.html#children)( ) ,返回一個[QObjectList](qobject.html#QObjectList-typedef)。[QObjectList](qobject.html#QObjectList-typedef)是一個typedef為[QList](index.htm)\u003cQObject *\u003e 。 ### No copy constructor or assignment operator QObject中既沒有拷貝構造函數,也不是一個賦值操作符。這是設計使然。實際上,它們被聲明,但在一個`private`與宏段[Q_DISABLE_COPY](qobject.html#Q_DISABLE_COPY)( ) 。事實上,自QObject (直接或間接)派生的所有Qt類使用這個宏來聲明自己的拷貝構造函數和賦值操作符是私有的。其理由是在討論中找到[Identity vs Value](index.htm#identity-vs-value)在Qt的[Object Model](index.htm)頁面。 主要的后果是,你應該使用指針的QObject (或您的QObject的子類) ,你可能被誘惑去使用QObject的子類作為值。例如,如果沒有拷貝構造函數,則不能使用的QObject的子類將其存儲在容器類中的一個值。你必須存儲的指針。 ### Auto-Connection Qt的元對象系統提供了一種機制來自動連接QObject的子類與子女之間的信號和槽。只要對象與合適的對象名稱來定義的,與插槽遵循一個簡單的命名慣例,這種連接可以在運行時被執行[QMetaObject.connectSlotsByName](qmetaobject.html#connectSlotsByName)()函數。 [uic](index.htm#uic)生成調用這個函數被用在創建窗體小部件之間進行,以啟用自動連接代碼_Qt Designer_。有關使用帶自動連接的詳細信息_Qt Designer_是由于在[Using a Designer UI File in Your Application](index.htm)的節_Qt Designer_手冊。 ### Dynamic Properties 從Qt 4.2中,動態屬性可以被添加到和從在運行時QObject的實例中刪除。動態屬性不需要在編譯時被聲明,但它們提供了相同的優點的靜態屬性和使用相同的API等的操作 - 使用[property](qobject.html#property)()來讀取它們,[setProperty](qobject.html#setProperty)( )來寫他們。 在Qt 4.3 ,動態屬性是由支持[Qt Designer](index.htm#the-property-editor),以及標準Qt控件和用戶創建的表格可以給出動態屬性。 ### Internationalization (i18n) 所有的QObject子類支持Qt的翻譯功能,使其能夠翻譯應用程序的用戶界面為不同的語言。 為了讓用戶可見的文本翻譯,它必須被包裹在調用[tr](qobject.html#tr)()函數。此進行了詳細的解釋[Writing Source Code for Translation](index.htm)文檔。 * * * ## Method Documentation ``` QObject.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個對象的父對象_parent_。 一個對象的父對象可以被視為對象的所有者。例如,一個[dialog box](qdialog.html)是父**OK**和**Cancel**按鈕,它包含的內容。 父對象的析構函數銷毀所有子對象。 Setting _parent_0構造一個對象沒有父。如果對象是一個小部件,它會成為一個頂級窗口。 **See also** [parent](qobject.html#parent)( )[findChild](qobject.html#findChild)()和[findChildren](qobject.html#findChildren)( ) 。 ``` bool QObject.blockSignals (self, bool?b) ``` If _block_誠然,此對象發出的信號被阻塞(即,發射的信號不會調用任何連接到它) 。如果_block_是假的,不會發生這樣的阻塞。 返回值是以前的值[signalsBlocked](qobject.html#signalsBlocked)( ) 。 注意,這個[destroyed](qobject.html#destroyed)( )信號,即使此對象的信號已經被封鎖發射。 **See also** [signalsBlocked](qobject.html#signalsBlocked)( ) 。 ``` QObject.childEvent (self, QChildEvent) ``` 此事件處理程序可以重新實現在子類中接收子事件。該事件被傳遞的_event_參數。 [QEvent.ChildAdded](qevent.html#Type-enum)和[QEvent.ChildRemoved](qevent.html#Type-enum)事件被發送到對象時,孩子們被添加或刪除。在這兩種情況下,你只能依靠孩子作為一個[QObject](qobject.html),或者如果[isWidgetType](qobject.html#isWidgetType)( )返回True ,一[QWidget](qwidget.html)。 (這是因為,在[ChildAdded](qevent.html#Type-enum)情況下,孩子還沒有完全建成,并在[ChildRemoved](qevent.html#Type-enum)情況下,它可能已被破壞的話) 。 [QEvent.ChildPolished](qevent.html#Type-enum)事件發送到窗口部件時,孩子們都經過拋光處理,或打磨時,孩子們補充說。如果您收到一個孩子拋光事件,孩子的建造通常完成。然而,這并不能完全保證,并且多個拋光事件可能Widget的構造函數的執行過程中被傳遞。 對于每個子控件,您收到一個[ChildAdded](qevent.html#Type-enum)事件,零個或多個[ChildPolished](qevent.html#Type-enum)事件,和一個[ChildRemoved](qevent.html#Type-enum)事件。 該[ChildPolished](qevent.html#Type-enum)如果一個孩子被立即刪除它被添加后,事件被省略。如果一個孩子被構造和析構過程中進行多次打磨,您可能會收到多個孩子拋光事件相同的孩子,每次使用不同的虛表。 **See also** [event](qobject.html#event)( ) 。 ``` list-of-QObject QObject.children (self) ``` 返回子對象的列表。該[QObjectList](qobject.html#QObjectList-typedef)類中所定義的`&lt;QObject&gt;`頭文件如下: ``` typedef [QList](index.htm)<[QObject](qobject.html)*> [QObjectList](qobject.html#QObjectList-typedef); ``` 添加的第一個孩子是[first](index.htm#first)在添加列表和最后一個子對象是[last](index.htm#last)列表中的對象,即新的兒童將被附加在最后。 請注意,該列表中的順序改變時,[QWidget](qwidget.html)孩子們[raised](qwidget.html#raise) or [lowered](qwidget.html#lower)。所提出的一個小部件成為列表中的最后一個對象,并且被降低一個小部件成為列表中的第一個對象。 **See also** [findChild](qobject.html#findChild)( )[findChildren](qobject.html#findChildren)( )[parent](qobject.html#parent)()和[setParent](qobject.html#setParent)( ) 。 ``` bool QObject.connect (QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType?=?Qt.AutoConnection) ``` 產生的給定的連接_type_從_signal_在_sender_反對_method_在_receiver_對象。返回True如果連接成功,否則返回False 。 您必須使用`SIGNAL()`和`SLOT()`當指定的宏_signal_和_method_例如: ``` [QLabel](qlabel.html) *label = new [QLabel](qlabel.html); [QScrollBar](qscrollbar.html) *scrollBar = new [QScrollBar](qscrollbar.html); [QObject](qobject.html).connect(scrollBar, SIGNAL(valueChanged(int)), label, SLOT(setNum(int))); ``` 這個例子可以確保標籤始終顯示當前滾動條的值。注意,信號和槽的參數必須不包含任何變量名,只有類型。例如以下是行不通的,并返回False : ``` // WRONG [QObject](qobject.html).connect(scrollBar, SIGNAL(valueChanged(int value)), label, SLOT(setNum(int value))); ``` 的信號也可以被連接到另一個信號: ``` class MyWidget : public [QWidget](qwidget.html) { Q_OBJECT public: MyWidget(); signals: void buttonClicked(); private: [QPushButton](qpushbutton.html) *myButton; }; MyWidget.MyWidget() { myButton = new [QPushButton](qpushbutton.html)(this); connect(myButton, SIGNAL(clicked()), this, SIGNAL(buttonClicked())); } ``` 在該示例中,`MyWidget`構造函數從一個私有成員變量繼電器的信號,并使其可下,涉及到一個名稱`MyWidget`。 一個信號可以連接到多個插槽和信號。很多信號可以連接到一個時隙。 如果一個信號被連接到多個槽,這些槽以相同的順序被激活作為連接被做,當信號被發射的次序。 如果它成功地將信號與槽連接的函數返回True。它會返回False ,如果它不能建立連接,例如,如果[QObject](qobject.html)無法驗證或者存在_signal_ or _method_,或者如果他們的簽名是不兼容的。 默認情況下,一個信號被發射為你傾盡連接;兩個信號發出重復的連接。你可以打破所有這些連接與單個[disconnect](qobject.html#disconnect)( )調用。如果你通過了[Qt.UniqueConnection](qt.html#ConnectionType-enum) _type_,連接將僅當它是不重復進行。如果已經有一個重復(完全相同的信號,對相同的對象完全相同的插槽) ,連接將失敗,連接將返回False 。 可選的_type_參數描述了連接建立的類型。特別是,它確定一個特定的信號是否被傳遞到緊接在一個時隙或排隊等待傳遞在以后的時間。如果信號排隊,該參數必須是已知Qt的元對象系統類型,因為Qt的需要復制到它們存儲在幕后事件的參數。如果您嘗試使用一個排隊的連接,并收到錯誤消息 ``` [QObject](qobject.html).connect: Cannot queue arguments of type 'MyType' (Make sure 'MyType' is registered using qRegisterMetaType().) ``` 通話[qRegisterMetaType](qmetatype.html#qRegisterMetaType)()注冊的數據類型你建立連接之前。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [disconnect](qobject.html#disconnect)( )[sender](qobject.html#sender)( )[qRegisterMetaType](qmetatype.html#qRegisterMetaType)()和[Q_DECLARE_METATYPE](qmetatype.html#Q_DECLARE_METATYPE)( ) 。 ``` bool QObject.connect (QObject, SIGNAL(), callable, Qt.ConnectionType?=?Qt.AutoConnection) ``` 產生的給定的連接_type_從_signal_在_sender_反對_method_在_receiver_對象。返回True如果連接成功,否則返回False 。 該功能的工作原理相同的方式連接(常量[QObject](qobject.html)*發件人,為const char *的信號,常量[QObject](qobject.html)*接收器,為const char *的方法,[Qt.ConnectionType](qt.html#ConnectionType-enum)型),但它使用了[QMetaMethod](qmetamethod.html)指定信號和方法。 此功能被引入Qt的4.8 。 **See also**連接(常量的QObject *寄件人,為const char *的信號,常量的QObject *接收器,為const char *的方法, Qt.ConnectionType型) 。 ``` bool QObject.connect (self, QObject, SIGNAL(), SLOT(), Qt.ConnectionType?=?Qt.AutoConnection) ``` 這個函數的重載[connect](qobject.html#connect)( ) 。 連接型_signal_從_sender_反對此對象的_method_。 相當于連接(_sender_,_signal_,`this`,_method_,_type_) 。 你讓每個連接發射信號,所以重復的連接發出兩個信號。您可以使用破解的連接[disconnect](qobject.html#disconnect)( ) 。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [disconnect](qobject.html#disconnect)( ) 。 ``` QObject.connectNotify (self, SIGNAL()?signal) ``` 這個虛函數被調用時,事情已經連接到_signal_在這個對象。 如果你想比較_signal_與一個特定的信號,使用[QLatin1String](qlatin1string.html)和`SIGNAL()`宏如下: ``` if (QLatin1String(signal) == SIGNAL(valueChanged(int))) { // signal is valueChanged(int) } ``` 如果信號中包含有空格,調用多個參數或參數[QMetaObject.normalizedSignature](qmetaobject.html#normalizedSignature)( )上的結果`SIGNAL()`宏。 **Warning:**此功能違反了模塊化的面向對象的原則。但是,當您需要執行昂貴的初始化只有當事情被連接到一個信號它可能是有用的。 **See also** [connect](qobject.html#connect)()和[disconnectNotify](qobject.html#disconnectNotify)( ) 。 ``` QObject.customEvent (self, QEvent) ``` 此事件處理程序可以重新實現在子類中以接收自定義事件。自定義事件是與類型值至少一樣大的用戶定義事件[QEvent.User](qevent.html#Type-enum)的產品[QEvent.Type](qevent.html#Type-enum)枚舉,并且是一個典型的[QEvent](qevent.html)子類。該事件被傳遞的_event_參數。 **See also** [event](qobject.html#event)()和[QEvent](qevent.html)。 ``` QObject.deleteLater (self) ``` 這種方法也是一個Qt槽與C + +的簽名`void deleteLater()`。 附表這個對象為刪除。 該對象將被當控制返回到事件循環中刪除。如果事件循環不運行時,這個函數被調用(例如deleteLater ( )被調用某個對象之前[QCoreApplication.exec](qcoreapplication.html#exec)()) ,當事件循環被啟動的對象都將被刪除。如果deleteLater ( )被調用后,主事件循環已經停止,對象不會被刪除。由于Qt的4.8 ,如果deleteLater ( )被調用的對象生活在一個線程沒有正在運行的事件循環時,對象將在線程結束時銷毀。 需要注意的是進入和離開一個新的事件循環(例如,通過打開一個模態對話框)會_not_執行延期刪除,因為要刪除的對象時,控件必須返回到事件循環從deleteLater ()被調用。 **Note:**它是安全的調用這個函數不止一次,當第一遞延刪除事件被交付,對于對象的任何掛起的事件從事件隊列中刪除。 **See also** [destroyed](qobject.html#destroyed)()和[QPointer](index.htm)。 ``` bool QObject.disconnect (QObject, SIGNAL(), QObject, SLOT()) ``` 斷開連接_signal_在對象_sender_從_method_在對象_receiver_。返回True如果連接成功打破,否則返回False 。 時,無論所涉及的對象被銷毀被刪除的信號 - 槽連接。 斷開( )通常用于三種方式,如下面的示例演示。 1. 斷開所有連接到一個對象的信號: ``` disconnect(myObject, 0, 0, 0); ``` 相當于非靜態重載函數 ``` myObject-&gt;disconnect(); ``` 2. 斷開所有連接到特定的信號: ``` disconnect(myObject, SIGNAL(mySignal()), 0, 0); ``` 相當于非靜態重載函數 ``` myObject-&gt;disconnect(SIGNAL(mySignal())); ``` 3. 斷開一個特定的接收器: ``` disconnect(myObject, 0, myReceiver, 0); ``` 相當于非靜態重載函數 ``` myObject-&gt;disconnect(myReceiver); ``` 0可以用作一個通配符,意思是“任何信號” , “任何接收對象” ,或“接收對象中的任何槽” ,分別。 該_sender_可能永遠不會為0。 (你不能從一個單一的呼叫多個對象斷開信號。 ) If _signal_為0時,斷開_receiver_和_method_從任何信號。如果不是這樣,只有指定的信號斷開。 If _receiver_為0時,斷開任何連接到_signal_。如果沒有,插槽對象以外_receiver_沒有斷開。 If _method_為0時,它斷開連接到任何_receiver_。如果沒有,只是插槽命名_method_將被斷開,而所有其他插槽單獨留在家中。該_method_必須為0 ,如果_receiver_被冷落,所以你不能斷開所有對象具體命名的插槽。 **Note:**這個功能是[thread-safe](index.htm#thread-safe)。 **See also** [connect](qobject.html#connect)( ) 。 ``` bool QObject.disconnect (QObject, SIGNAL(), callable) ``` 斷開連接_signal_在對象_sender_從_method_在對象_receiver_。返回True如果連接成功打破,否則返回False 。 此功能提供了像斷開(常量相同的可能性[QObject](qobject.html)*發件人,為const char *的信號,常量[QObject](qobject.html)*接收器,為const char *法),但用途[QMetaMethod](qmetamethod.html)代表要被斷開的信號,并且該方法。 此外,此功能returnsFalse ,無信號和槽斷開,如果: 1. _signal_是不是發件人類的成員或其父類之一。 2. _method_是不是接收器類的成員或其父類之一。 3. _signal_實例表示沒有信號。 QMetaMethod ( )可以被用作通配符的意思是“任何信號”或“接收對象中的任何槽” 。以同樣的方式0可用于_receiver_中的含義是“任何接收對象” 。在這種情況下,方法也應該QMetaMethod () 。_sender_參數應該是永遠不為0 。 此功能被引入Qt的4.8 。 **See also**斷開(常量的QObject *寄件人,為const char *的信號,常量的QObject *接收器,為const char *的方法) 。 ``` QObject.disconnectNotify (self, SIGNAL()?signal) ``` 當事情已經斷開從這個虛函數被調用_signal_在這個對象。 See [connectNotify](qobject.html#connectNotify)( )對于如何比較的例子_signal_與特定的信號。 **Warning:**此功能違反了模塊化的面向對象的原則。但是,它可能是最優化使用昂貴的資源是有用的。 **See also** [disconnect](qobject.html#disconnect)()和[connectNotify](qobject.html#connectNotify)( ) 。 ``` QObject.dumpObjectInfo (self) ``` 轉儲有關信號連接信息等,為這個對象的調試輸出。 此功能對于調試非常有用,但什么都不做,如果該庫已經在釋放模式編譯(即沒有調試信息) 。 **See also** [dumpObjectTree](qobject.html#dumpObjectTree)( ) 。 ``` QObject.dumpObjectTree (self) ``` 兒童轉儲到調試輸出的一棵樹。 此功能對于調試非常有用,但什么都不做,如果該庫已經在釋放模式編譯(即沒有調試信息) 。 **See also** [dumpObjectInfo](qobject.html#dumpObjectInfo)( ) 。 ``` list-of-QByteArray QObject.dynamicPropertyNames (self) ``` 返回所有屬性,是使用動態添加到該對象的名稱[setProperty](qobject.html#setProperty)( ) 。 這個函數中引入了Qt 4.2中。 ``` QObject.emit (self, SIGNAL(), ...) ``` ``` bool QObject.event (self, QEvent) ``` 這個虛函數接收事件的對象,應該返回True,如果事件_e_確認和處理。 本次活動( )函數可重新實現以自定義對象的行為。 **See also** [installEventFilter](qobject.html#installEventFilter)( )[timerEvent](qobject.html#timerEvent)( )[QApplication.sendEvent](qcoreapplication.html#sendEvent)( )[QApplication.postEvent](qcoreapplication.html#postEvent)()和[QWidget.event](qwidget.html#event)( ) 。 ``` bool QObject.eventFilter (self, QObject, QEvent) ``` 過濾器的事件,如果這個對象已經被安裝為一個事件過濾器_watched_對象。 在你這個函數的重新實現,如果你要篩選的_event_出,正在進一步處理即停止,返回True ,否則返回False 。 例如: ``` class MainWindow : public [QMainWindow](qmainwindow.html) { public: MainWindow(); protected: bool eventFilter([QObject](qobject.html) *obj, [QEvent](qevent.html) *ev); private: [QTextEdit](qtextedit.html) *textEdit; }; MainWindow.MainWindow() { textEdit = new [QTextEdit](qtextedit.html); setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow.eventFilter([QObject](qobject.html) *obj, [QEvent](qevent.html) *event) { if (obj == textEdit) { if (event->type() == [QEvent](qevent.html).KeyPress) { [QKeyEvent](qkeyevent.html) *keyEvent = static_cast<[QKeyEvent](qkeyevent.html)*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return [QMainWindow](qmainwindow.html).eventFilter(obj, event); } } ``` 在上面的未處理的事件為例通知傳遞給基類的eventFilter ( )函數,因為基類有可能重新實現eventFilter ( )為自己的內部目的。 **Warning:**如果您刪除的接收器對象在這個函數中,一定要返回True 。否則,將Qt的事件轉發到已刪除對象,程序可能會崩潰。 **See also** [installEventFilter](qobject.html#installEventFilter)( ) 。 ``` QObject QObject.findChild (self, type?type, QString?name?=?QString()) ``` 返回此對象的子對象可以強制轉換為類型T和那個叫_name_或0,如果不存在這樣的對象。省略_name_參數會導致要匹配所有對象名稱。搜索被遞歸執行。 如果有一個以上的孩子匹配搜索,返回最直接的祖先。如果有多個直系祖先,它是不確定哪一個將被退回。在這種情況下,[findChildren](qobject.html#findChildren)( )應該被使用。 此示例返回一個孩子[QPushButton](qpushbutton.html)的`parentWidget` named `"button1"`: ``` [QPushButton](qpushbutton.html) *button = parentWidget->findChild<[QPushButton](qpushbutton.html) *>("button1"); ``` 此示例返回一個[QListWidget](qlistwidget.html)兒童`parentWidget`: ``` [QListWidget](qlistwidget.html) *list = parentWidget->findChild<[QListWidget](qlistwidget.html) *>(); ``` **See also** [findChildren](qobject.html#findChildren)( ) 。 ``` QObject QObject.findChild (self, tuple?types, QString?name?=?QString()) ``` ``` list-of-QObject QObject.findChildren (self, type?type, QString?name?=?QString()) ``` 返回此對象的所有子具有給定_name_可以強制轉換為類型T,或者一個空列表,如果沒有這樣的對象。省略_name_參數會導致要匹配所有對象名稱。搜索被遞歸執行。 下面的示例演示如何找到孩子的名單[QWidget](qwidget.html)指定的第`parentWidget` named `widgetname`: ``` [QList](index.htm)<[QWidget](qwidget.html) *> widgets = parentWidget.findChildren<[QWidget](qwidget.html) *>("widgetname"); ``` 此示例返回所有`QPushButton`s表示是兒童`parentWidget`: ``` [QList](index.htm)<[QPushButton](qpushbutton.html) *> allPButtons = parentWidget.findChildren<[QPushButton](qpushbutton.html) *>(); ``` **See also** [findChild](qobject.html#findChild)( ) 。 ``` list-of-QObject QObject.findChildren (self, tuple?types, QString?name?=?QString()) ``` 這個函數的重載[findChildren](qobject.html#findChildren)( ) 。 返回此對象的可強制轉換為類型T和其名稱匹配正則表達式的孩子_regExp_,或者一個空列表,如果沒有這樣的對象。搜索被遞歸執行。 ``` list-of-QObject QObject.findChildren (self, type?type, QRegExp?regExp) ``` ``` list-of-QObject QObject.findChildren (self, tuple?types, QRegExp?regExp) ``` ``` bool QObject.inherits (self, str?classname) ``` 返回True如果這個對象是一個類繼承的一個實例_className_或[QObject](qobject.html)子類繼承_className_否則返回False 。 一類被認為是繼承本身。 例如: ``` [QTimer](qtimer.html) *timer = new [QTimer](qtimer.html); // QTimer inherits QObject timer->inherits("QTimer"); // returns true timer->inherits("QObject"); // returns true timer->inherits("QAbstractButton"); // returns false // QVBoxLayout inherits QObject and QLayoutItem [QVBoxLayout](qvboxlayout.html) *layout = new [QVBoxLayout](qvboxlayout.html); layout->inherits("QObject"); // returns true layout->inherits("QLayoutItem"); // returns true (even though QLayoutItem is not a QObject) ``` 如果您需要確定一個對象是否為鑄造它的目的一個特定的類的實例,可以考慮使用qobject_cast \u003cType *\u003e (對象)來代替。 **See also** [metaObject](qobject.html#metaObject)()和[qobject_cast](qobject.html#qobject_cast)( ) 。 ``` QObject.installEventFilter (self, QObject) ``` 安裝一個事件過濾器_filterObj_此對象上。例如: ``` monitoredObj->installEventFilter(filterObj); ``` 事件過濾器是接收發送到該對象的所有事件的對象。該過濾器可以阻止事件或將其轉發到該對象。事件過濾器_filterObj_通過接收其事件[eventFilter](qobject.html#eventFilter)()函數。該[eventFilter](qobject.html#eventFilter)( )函數必須返回True,如果該事件應該被過濾, (即停止) ,否則它必須返回False 。 如果有多個事件過濾器被安裝在一個單獨的對象,這是最后安裝的過濾器將首先啟動。 這里有一個`KeyPressEater`類,吃它的被監控對象的按鍵: ``` class KeyPressEater : public [QObject](qobject.html) { Q_OBJECT ... protected: bool eventFilter([QObject](qobject.html) *obj, [QEvent](qevent.html) *event); }; bool KeyPressEater.eventFilter([QObject](qobject.html) *obj, [QEvent](qevent.html) *event) { if (event->type() == [QEvent](qevent.html).KeyPress) { [QKeyEvent](qkeyevent.html) *keyEvent = static_cast<[QKeyEvent](qkeyevent.html) *>(event); qDebug("Ate key press %d", keyEvent->key()); return true; } else { // standard event processing return [QObject](qobject.html).eventFilter(obj, event); } } ``` 下面是如何在兩個窗口小部件安裝它: ``` KeyPressEater *keyPressEater = new KeyPressEater(this); [QPushButton](qpushbutton.html) *pushButton = new [QPushButton](qpushbutton.html)(this); [QListView](qlistview.html) *listView = new [QListView](qlistview.html)(this); pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater); ``` 該[QShortcut](qshortcut.html)類,例如,使用這種技術來截取快捷按鍵。 **Warning:**如果您刪除的接收器對象中的[eventFilter](qobject.html#eventFilter)( )函數時,一定要返回True 。如果返回False , Qt的發送事件到已刪除對象,程序會崩潰。 需要注意的是過濾對象必須在同一個線程中此對象。如果_filterObj_是在不同的線程,這個函數不執行任何操作。如果任_filterObj_或對該對象的調用此函數后移動到一個不同的線程,事件過濾器不會被調用,直到兩個對象又具有相同的線程關聯(這是_not_刪除)。 **See also** [removeEventFilter](qobject.html#removeEventFilter)( )[eventFilter](qobject.html#eventFilter)()和[event](qobject.html#event)( ) 。 ``` bool QObject.isWidgetType (self) ``` 返回True如果該對象是一個小部件,否則返回False 。 調用此函數相當于調用繼承( “[QWidget](qwidget.html)“ ) ,不同的是它的速度要快得多。 ``` QObject.killTimer (self, int?id) ``` 殺死定時器,具有定時器標識符,_id_。 定時器標識符由返回[startTimer](qobject.html#startTimer)( )啟動一個計時器事件時。 **See also** [timerEvent](qobject.html#timerEvent)()和[startTimer](qobject.html#startTimer)( ) 。 ``` QMetaObject QObject.metaObject (self) ``` [ 返回一個指向該對象的元對象。 ](qmetaobject.html) [一個元對象包含有關一個繼承信息](qmetaobject.html)[QObject](qobject.html)如類名,父名,屬性,信號和槽。一切[QObject](qobject.html)子類,它包含了[Q_OBJECT](qobject.html#Q_OBJECT)宏將有一個元對象。 元對象信息所必需的信號/插槽連接機制和產權制度。該[inherits](qobject.html#inherits)( )函數也使用的元對象。 如果你沒有指向一個實際的對象實例,但仍希望訪問類的元對象,你可以使用[staticMetaObject](qobject.html#staticMetaObject-var)。 例如: ``` [QObject](qobject.html) *obj = new [QPushButton](qpushbutton.html); obj->metaObject()->className(); // returns "QPushButton" [QPushButton](qpushbutton.html).staticMetaObject.className(); // returns "QPushButton" ``` **See also** [staticMetaObject](qobject.html#staticMetaObject-var)。 ``` QObject.moveToThread (self, QThread?thread) ``` 為改變此對象及其子對象的線程關聯。如果它有一個父對象不能被移動。事件處理將繼續在_targetThread_。 移動對象到主線程,使用[QApplication.instance](qcoreapplication.html#instance)( )來檢索一個指向當前的應用程序,然后使用[QApplication.thread](qobject.html#thread)( )來檢索應用程序在其中居住的線程。例如: ``` myObject->moveToThread([QApplication](qapplication.html).instance()->thread()); ``` If _targetThread_是零,此對象及其子所有的事件處理停止。 需要注意的是所有活動的定時器對象將被重置。該定時器在當前線程先停止并重新啟動(以相同的時間間隔)中的_targetThread_。因此,不斷移動的對象的線程之間可以無限期地推遲計時器事件。 A [QEvent.ThreadChange](qevent.html#Type-enum)事件被發送到該對象的線程關聯被改變之前。您可以處理這個事件來執行任何特殊處理。需要注意的是投遞到該對象的任何新的事件將在被處理_targetThread_。 **Warning:**這個功能是_not_線程安全的;當前線程必須是與當前線程關聯。換句話說,這個函數可以僅“推”從當前線程到另一個線程一個對象,它不能從任意線程“拉”的對象到當前線程。 **See also** [thread](qobject.html#thread)( ) 。 ``` QString QObject.objectName (self) ``` ``` QObject QObject.parent (self) ``` [ 返回一個指向父對象。 ](qobject.html) [**See also**](qobject.html) [setParent](qobject.html#setParent)()和[children](qobject.html#children)( ) 。 ``` QVariant QObject.property (self, str?name) ``` 返回該對象的值_name_屬性。 如果沒有這樣的屬性存在,則返回的變量是無效的。 有關所有可用屬性的信息是通過提供[metaObject](qobject.html#metaObject)()和[dynamicPropertyNames](qobject.html#dynamicPropertyNames)( ) 。 **See also** [setProperty](qobject.html#setProperty)(), [QVariant.isValid](qvariant.html#isValid)(), [metaObject](qobject.html#metaObject)(), and [dynamicPropertyNames](qobject.html#dynamicPropertyNames)(). ``` QObject.pyqtConfigure (self, object) ``` ``` int QObject.receivers (self, SIGNAL()?signal) ``` 返回連接到所述接收器的數量_signal_。 因為這兩個槽和信號可以被用作接收器的信號,并且在同一連接可以被多次提出,接收機的數目是一樣的從該信號建立的連接的數量。 當調用這個函數,你可以使用`SIGNAL()`宏來傳遞一個特定的信號: ``` if (receivers(SIGNAL(valueChanged([QByteArray](qbytearray.html)))) > 0) { [QByteArray](qbytearray.html) data; get_the_value(&data); // expensive operation emit valueChanged(data); } ``` 正如上面的代碼片段所示,您可以使用此功能來避免發出一個信號,即沒有人聽。 **Warning:**此功能違反了模塊化的面向對象的原則。但是,當您需要執行昂貴的初始化只有當事情被連接到一個信號它可能是有用的。 ``` QObject.removeEventFilter (self, QObject) ``` 刪除事件過濾器對象_obj_從該對象。如果這樣的事件過濾器尚未安裝該請求將被忽略。 此對象的所有事件過濾器時,這個對象被銷毀被自動刪除。 它始終是安全的,從刪除事件過濾器,即使在事件過濾器激活(即[eventFilter](qobject.html#eventFilter)()函數) 。 **See also** [installEventFilter](qobject.html#installEventFilter)( )[eventFilter](qobject.html#eventFilter)()和[event](qobject.html#event)( ) 。 ``` QObject QObject.sender (self) ``` [ 返回一個指針,指向發送的信號,如果調用了一個信號激活一個插槽中的對象,否則返回0 。僅在從該對象的線程上下文中調用這個函數插槽的執行指針是有效的。 這個函數返回的指針變為無效,如果發件人被破壞,或者如果插槽是從發件人的信號斷開。 **Warning:**此功能違反了模塊化的面向對象的原則。然而,當許多信號被連接到一個單一的時隙獲得訪問發件人可能是有用的。 ](qobject.html) [**Warning:**如上所述,該函數的返回值不是有效的,當槽是通過一個稱為](qobject.html)[Qt.DirectConnection](qt.html#ConnectionType-enum)從一個線程從該對象的線程不同。不要在這種情形下使用該功能。 **See also** [senderSignalIndex](qobject.html#senderSignalIndex)()和[QSignalMapper](qsignalmapper.html)。 ``` int QObject.senderSignalIndex (self) ``` 返回調用當前正在執行的插槽中的信號,這是由返回的類的一個成員的元方法指數[sender](qobject.html#sender)( ) 。如果由一個信號激活的插槽外調用,則返回-1。 對于使用默認參數信號,該功能將始終返回索引的所有參數,無論哪個與使用[connect](qobject.html#connect)( ) 。例如,信號`destroyed(QObject *obj = 0)`將有兩個不同的索引(使用和不使用參數) ,但這個函數將總是用參數返回的索引。使用不同的參數重載信號時,這并不適用。 **Warning:**此功能違反了模塊化的面向對象的原則。然而,當許多信號被連接到一個單一的時隙獲得訪問信號索引可能是有用的。 **Warning:**這個函數的返回值不是有效的,當槽通過一個名為[Qt.DirectConnection](qt.html#ConnectionType-enum)從一個線程從該對象的線程不同。不要在這種情形下使用該功能。 此功能被引入Qt的4.8 。 **See also** [sender](qobject.html#sender)( )[QMetaObject.indexOfSignal](qmetaobject.html#indexOfSignal)()和[QMetaObject.method](qmetaobject.html#method)( ) 。 ``` QObject.setObjectName (self, QString?name) ``` ``` QObject.setParent (self, QObject) ``` 該_QObject_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 使對象的子_parent_。 **See also** [parent](qobject.html#parent)()和[QWidget.setParent](qwidget.html#setParent)( ) 。 ``` bool QObject.setProperty (self, str?name, QVariant?value) ``` 設置對象的值_name_屬性為_value_。 如果該屬性在類使用Q_PROPERTY定義,那么真正的成功,否則為False返回。如果屬性不使用Q_PROPERTY定義,因此在元對象不在列表中,它被添加為一個動態屬性并返回False 。 有關所有可用屬性的信息是通過提供[metaObject](qobject.html#metaObject)()和[dynamicPropertyNames](qobject.html#dynamicPropertyNames)( ) 。 動態屬性可以再次使用查詢[property](qobject.html#property)() ,并且可以通過將屬性值設置為無效去除[QVariant](qvariant.html)。更改動態屬性的值將導致[QDynamicPropertyChangeEvent](qdynamicpropertychangeevent.html)要發送到的對象。 **Note:**以“ _q_ ”動態屬性是供內部使用保留的。 **See also** [property](qobject.html#property)( )[metaObject](qobject.html#metaObject)()和[dynamicPropertyNames](qobject.html#dynamicPropertyNames)( ) 。 ``` bool QObject.signalsBlocked (self) ``` 如果返回的信號被阻斷True,否則返回False 。 信號不默認情況下阻止。 **See also** [blockSignals](qobject.html#blockSignals)( ) 。 ``` int QObject.startTimer (self, int?interval) ``` 啟動一個定時器,并返回一個定時器標識符,或返回零,如果它不能啟動一個定時器。 定時器事件會發生一次_interval_直到毫秒[killTimer](qobject.html#killTimer)()被調用。如果_interval_是0,那么該定時事件,每次有沒有更多的窗口系統事件來處理發生一次。 虛擬[timerEvent](qobject.html#timerEvent)( )函數被調用,[QTimerEvent](qtimerevent.html)當計時器事件發生的事件參數類。重新實現這個函數來獲取計時器事件。 如果多個定時器在運行,[QTimerEvent.timerId](qtimerevent.html#timerId)( )可以用來找出哪些定時器被激活。 例如: ``` class MyObject : public [QObject](qobject.html) { Q_OBJECT public: MyObject([QObject](qobject.html) *parent = 0); protected: void timerEvent([QTimerEvent](qtimerevent.html) *event); }; MyObject.MyObject([QObject](qobject.html) *parent) : [QObject](qobject.html)(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer } void MyObject.timerEvent([QTimerEvent](qtimerevent.html) *event) { qDebug() << "Timer ID:" << event->timerId(); } ``` 需要注意的是[QTimer](qtimer.html)的精度依賴于底層的操作系統和硬件。大多數平臺支持20毫秒的精度,有的提供更多。如果Qt是無法提供的定時器事件的請求數量,它會悄悄地丟棄一些。 該[QTimer](qtimer.html)類提供了一個高層次的編程接口與單次定時器和定時信號,而不是事件。還有一個[QBasicTimer](qbasictimer.html)類是比更輕巧[QTimer](qtimer.html)而不是直接使用定時器的ID少笨拙。 **See also** [timerEvent](qobject.html#timerEvent)( )[killTimer](qobject.html#killTimer)()和[QTimer.singleShot](qtimer.html#singleShot)( ) 。 ``` QThread QObject.thread (self) ``` [ 返回該對象所居住的線程。 ](qthread.html) [**See also**](qthread.html) [moveToThread](qobject.html#moveToThread)( ) 。 ``` QObject.timerEvent (self, QTimerEvent) ``` 此事件處理程序可以重新實現在子類來接收定時器事件的對象。 [QTimer](qtimer.html)提供了一個更高層次的接口,定時器功能,也關于定時器的更多的一般信息。計時器事件被傳遞的_event_參數。 **See also** [startTimer](qobject.html#startTimer)( )[killTimer](qobject.html#killTimer)()和[event](qobject.html#event)( ) 。 ``` QString QObject.tr (self, str?sourceText, str?disambiguation?=?None, int?n?=?-1) ``` 返回的翻譯版本_sourceText_任選地基于一個_disambiguation_字符串和值_n_包含復數字符串,否則返回_sourceText_本身如果沒有合適的翻譯的字符串是可用的。 例如: ``` void MainWindow.createMenus() { fileMenu = menuBar()->addMenu(tr("&File")); ... ``` 如果同一_sourceText_同一范圍內采用的是不同的角色,一個額外的標識字符串可以被傳遞_disambiguation_(默認為0 ) 。在Qt 4.4和更早的版本,這是通過注釋來翻譯的首選方式。 例如: ``` MyWindow.MyWindow() { [QLabel](qlabel.html) *senderLabel = new [QLabel](qlabel.html)(tr("Name:")); [QLabel](qlabel.html) *recipientLabel = new [QLabel](qlabel.html)(tr("Name:", "recipient")); ... ``` See [Writing Source Code for Translation](index.htm)對于Qt的翻譯機制在一般情況下,并詳細描述了[Disambiguation](index.htm#disambiguation)節,以消除歧義的信息。 **Warning:**這種方法是可重入只有在安裝了所有的翻譯_before_調用此方法。但不支持進行翻譯安裝或刪除翻譯。這樣做可能會造成崩潰或者其他不良行為。 **See also** [trUtf8](qobject.html#trUtf8)( )[QApplication.translate](qcoreapplication.html#translate)( )[QTextCodec.setCodecForTr](qtextcodec.html#setCodecForTr)()和[Internationalization with Qt](index.htm)。 ``` QString QObject.trUtf8 (self, str?sourceText, str?disambiguation?=?None, int?n?=?-1) ``` 返回的翻譯版本_sourceText_,或QString.fromUtf8 (_sourceText_) ,如果沒有適當的版本。它在其它方面與TR (_sourceText_,_disambiguation_,_n_) 。 請注意,使用的翻譯功能utf8的變種是不是如果需要的話`CODECFORTR`已被設置為UTF -8在qmake的項目文件和QTextCodec.setCodecForTr ( “UTF - 8” )被使用。 **Warning:**這種方法是可重入只有在安裝了所有的翻譯_before_調用此方法。但不支持進行翻譯安裝或刪除翻譯。這樣做可能會造成崩潰或者其他不良行為。 **Warning:**對于便攜性的原因,我們建議您使用轉義序列在字符串中指定非ASCII字符trUtf8 ( ) 。例如: ``` label->setText(tr("F\374r \310lise")); ``` **See also** [tr](qobject.html#tr)( )[QApplication.translate](qcoreapplication.html#translate)()和[Internationalization with Qt](index.htm)。 ``` object QObject.__getattr__ (self, str?name) ``` * * * ## Qt Signal Documentation ``` void destroyed (QObject * = 0) ``` 這是該信號的默認超載。 這個信號的對象之前立即發出_obj_被破壞,并且不能被阻塞。 所有對象的孩子被立即銷毀后,這個信號被發射。 **See also** [deleteLater](qobject.html#deleteLater)()和[QPointer](index.htm)。 * * * ## Member Documentation ``` QMetaObject staticMetaObject ``` [ 此構件應被視為常數。 這個變量存儲的元對象的類。 ](qmetaobject.html) [一個元對象包含有關一個繼承信息](qmetaobject.html)[QObject](qobject.html)如類名,父名,屬性,信號和槽。包含每個類的[Q_OBJECT](qobject.html#Q_OBJECT)宏也將有一個元對象。 元對象信息所必需的信號/插槽連接機制和產權制度。該[inherits](qobject.html#inherits)( )函數也使用的元對象。 如果你有一個指向對象的指針,你可以使用[metaObject](qobject.html#metaObject)()檢索與該對象關聯的元對象。 例如: ``` [QPushButton](qpushbutton.html).staticMetaObject.className(); // returns "QPushButton" [QObject](qobject.html) *obj = new [QPushButton](qpushbutton.html); obj->metaObject()->className(); // returns "QPushButton" ``` **See also** [metaObject](qobject.html#metaObject)( ) 。
                  <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>

                              哎呀哎呀视频在线观看