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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # QDeclarativeExtensionPlugin Class Reference ## [[QtDeclarative](index.htm) module] 該QDeclarativeExtensionPlugin類提供了一個抽象基自定義QML擴展插件。[More...](#details) 繼承[QObject](qobject.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `initializeEngine (self, QDeclarativeEngine?engine, str?uri)` * `registerTypes (self, str?uri)` * * * ## Detailed Description 該QDeclarativeExtensionPlugin類提供了一個抽象基自定義QML擴展插件。 QDeclarativeExtensionPlugin是一個插件接口,使得它可以創建能夠動態地加載到QML應用QML擴展。這些擴展允許自定義的QML類型被提供給QML引擎。 寫一個QML擴展插件: * Subclass QDeclarativeExtensionPlugin, implement [registerTypes](qdeclarativeextensionplugin.html#registerTypes)() method to register types using [qmlRegisterType](qdeclarativeengine.html#qmlRegisterType)(), and export the class using the [Q_EXPORT_PLUGIN2](index.htm#Q_EXPORT_PLUGIN2)() macro * Write an appropriate project file for the plugin * Create a [qmldir file](index.htm#writing-a-qmldir-file) to describe the plugin QML擴展插件可用于提供任何特定應用程序或庫類插件。圖書館插件應該限制自己注冊的類型,因為任何操作引擎的根上下文可能會導致在庫用戶的代碼沖突或其他問題。 ### An example 假設有一個新`TimeModel`C + +類應該提供一個新的QML元素。它提供了在當前時間通過`hour`和`minute`屬性,像這樣: ``` class TimeModel : public [QObject](qobject.html) { Q_OBJECT Q_PROPERTY(int hour READ hour NOTIFY timeChanged) Q_PROPERTY(int minute READ minute NOTIFY timeChanged) ... ``` 為了使這個類可以作為一個QML類型,創建一個插件,注冊這個類型與特定的[module](index.htm#qml-modules) using [qmlRegisterType](qdeclarativeengine.html#qmlRegisterType)( ) 。在這個例子中的插件模塊將被命名為`com.nokia.TimeExample`(如在下面進一步在項目文件中定義)。 ``` class QExampleQmlPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT public: void registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); qmlRegisterType<TimeModel>(uri, 1, 0, "Time"); } }; Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); ``` 這將注冊`TimeModel`級與1.0版本的插件庫,作為所謂的QML類型`Time`。該Q_ASSERT語句確保該模塊是通過使用這個插件的任何QML組件正確導入。 項目文件中的項目定義為一個插件庫,并指定它應該被內置到`com/nokia/TimeExample`目錄: ``` TEMPLATE = lib CONFIG += qt plugin QT += declarative DESTDIR = com/nokia/TimeExample TARGET = qmlqtimeexampleplugin ... ``` 最后,一個[qmldir file](index.htm#writing-a-qmldir-file)是需要在`com/nokia/TimeExample`目錄描述插件。此目錄包含一個`Clock.qml`應該與插件捆綁在一起,因此它需要在指定的文件`qmldir`文件: ``` Clock 1.0 Clock.qml plugin qmlqtimeexampleplugin ``` 一旦項目建成并安裝新的`Time`元素可以使用一個導入的任何QML組件`com.nokia.TimeExample`模塊: ``` import com.nokia.TimeExample 1.0 // import types from the plugin Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) Time { // this class is defined in C++ (plugin.cpp) id: time } hours: time.hour minutes: time.minute } ``` 完整的源代碼是可用[plugins example](index.htm)。 該[Tutorial: Writing QML extensions with C++](index.htm)還包含有關創建QML插件一章。 * * * ## Method Documentation ``` QDeclarativeExtensionPlugin.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個QML擴展插件與給定_parent_。 注意,此構造是由自動調用[Q_EXPORT_PLUGIN2](index.htm#Q_EXPORT_PLUGIN2)()宏,所以沒有必要顯式地調用它。 ``` QDeclarativeExtensionPlugin.initializeEngine (self, QDeclarativeEngine?engine, str?uri) ``` 初始化擴展從_uri_使用_engine_。在這里,一個應用程序的插件可能,例如,暴露一些數據或對象,以QML ,作為發動機的根上下文上下文屬性。 ``` QDeclarativeExtensionPlugin.registerTypes (self, str?uri) ``` 這種方法是抽象的,應在任何子類中重新實現。 寄存器的QML類型在給定的_uri_。子類應該實現這個調用[qmlRegisterType](qdeclarativeengine.html#qmlRegisterType)()為這是由擴展插件提供的所有類型。 該_uri_是一個標識符的基礎上擴展的插件庫的名稱和路徑由QML引擎生成的插件。
                  <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>

                              哎呀哎呀视频在线观看