<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # QDeclarativeEngine Class Reference ## [[QtDeclarative](index.htm) module] 該QDeclarativeEngine類提供了實例QML組件的環境。[More...](#details) 繼承[QObject](qobject.html)。 ### Types * `enum ObjectOwnership { CppOwnership, JavaScriptOwnership }` ### Methods * `__init__ (self, QObject?parent?=?None)` * `addImageProvider (self, QString?id, QDeclarativeImageProvider)` * `addImportPath (self, QString?dir)` * `addPluginPath (self, QString?dir)` * `QUrl baseUrl (self)` * `clearComponentCache (self)` * `QDeclarativeImageProvider imageProvider (self, QString?id)` * `QStringList importPathList (self)` * `(bool, QString?errorString) importPlugin (self, QString?filePath, QString?uri)` * `QNetworkAccessManager networkAccessManager (self)` * `QDeclarativeNetworkAccessManagerFactory networkAccessManagerFactory (self)` * `QString offlineStoragePath (self)` * `bool outputWarningsToStandardError (self)` * `QStringList pluginPathList (self)` * `removeImageProvider (self, QString?id)` * `QDeclarativeContext rootContext (self)` * `setBaseUrl (self, QUrl)` * `setImportPathList (self, QStringList?paths)` * `setNetworkAccessManagerFactory (self, QDeclarativeNetworkAccessManagerFactory)` * `setOfflineStoragePath (self, QString?dir)` * `setOutputWarningsToStandardError (self, bool)` * `setPluginPathList (self, QStringList?paths)` ### Static Methods * `QDeclarativeContext contextForObject (QObject)` * `ObjectOwnership objectOwnership (QObject)` * `setContextForObject (QObject, QDeclarativeContext)` * `setObjectOwnership (QObject, ObjectOwnership)` ### Qt Signals * `void quit ()` * `void warnings (const QList&lt;QDeclarativeError&gt;&)` * * * ## Detailed Description 該QDeclarativeEngine類提供了實例QML組件的環境。 每個QML組件實例化的[QDeclarativeContext](qdeclarativecontext.html)。[QDeclarativeContext](qdeclarativecontext.html)的是將數據傳遞到QML組件是必不可少的。在QML中,上下文是分級排列并且這個層次是由QDeclarativeEngine管理。 在此之前創建的任何QML組件,應用程序必須創建一個QDeclarativeEngine來訪問一個QML上下文。下面的示例顯示了如何創建一個簡單的文本項。 ``` QDeclarativeEngine engine; [QDeclarativeComponent](qdeclarativecomponent.html) component(&engine); component.setData("import QtQuick 1.0\nText { text: \"Hello world!\" }", [QUrl](qurl.html)()); [QDeclarativeItem](qdeclarativeitem.html) *item = qobject_cast<[QDeclarativeItem](qdeclarativeitem.html) *>(component.create()); //add item to view, etc ... ``` 在這種情況下,文本項目將在發動機的創建[root context](qdeclarativeengine.html#rootContext)。 * * * ## Type Documentation ``` QDeclarativeEngine.ObjectOwnership ``` 所有權控制QML是否自動銷毀[QObject](qobject.html)當對象被垃圾由JavaScript引擎收集。這兩種所有制的選項有: | Constant | Value | Description | | --- | --- | --- | | `QDeclarativeEngine.CppOwnership` | `0` | 對象是由C + +代碼擁有,永遠不會被QML被刪除。 JavaScript的destroy()方法不能與CppOwnership對象使用。此選項類似于[QScriptEngine.QtOwnership](qscriptengine.html#ValueOwnership-enum)。 | | `QDeclarativeEngine.JavaScriptOwnership` | `1` | 該目的是通過JavaScript的擁有。當對象被返回到QML作為一個方法調用或屬性訪問的返回值, QML會刪除該對象,如果有它沒有剩馀的JavaScript引用和它有沒有[QObject.parent](qobject.html#parent)( ) 。此選項類似于[QScriptEngine.ScriptOwnership](qscriptengine.html#ValueOwnership-enum)。 | 一般的應用程序并不需要顯式設置對象的所有權。 QML使用啟發式設置默認對象所有權。默認情況下,是通過QML創建一個對象有JavaScriptOwnership 。唯一的例外是通過調用QDeclarativeCompnent.create (創建的根對象)或[QDeclarativeComponent.beginCreate](qdeclarativecomponent.html#beginCreate)(),它在默認情況下已經CppOwnership 。這些根級對象的所有權被視為已轉移到C + +調用者。 通過QML不能創建對象具有CppOwnership默認。唯一的例外是一個C + +方法調用返回的對象。這些對象的所有權被傳遞給JavaScript 。 調用[setObjectOwnership](qdeclarativeengine.html#setObjectOwnership)( )復蓋使用QML默認所有權啟發式。 * * * ## Method Documentation ``` QDeclarativeEngine.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建一個新的[QDeclarativeEngine](qdeclarativeengine.html)用給定的_parent_。 ``` QDeclarativeEngine.addImageProvider (self, QString?id, QDeclarativeImageProvider) ``` 設置_provider_用于經由所請求的圖像_image_: URL方案,與主機_providerId_。該[QDeclarativeEngine](qdeclarativeengine.html)采取所有權_provider_。 圖片提供者能為像素圖和螺紋圖像請求支持。請參閱[QDeclarativeImageProvider](qdeclarativeimageprovider.html)文件中有關實施和使用圖像提供商的詳細信息。 所有所需的圖像提供商應該被添加到發動機的任何QML源之前文件被加載。 **See also** [removeImageProvider](qdeclarativeengine.html#removeImageProvider)( ) 。 ``` QDeclarativeEngine.addImportPath (self, QString?dir) ``` 添加_path_因為那里的搜索引擎在一個基于URL的目錄結構安裝的模塊目錄。該_path_可以是本地文件系統的目錄或URL。 新添加的_path_將首先在[importPathList](qdeclarativeengine.html#importPathList)( ) 。 **See also** [setImportPathList](qdeclarativeengine.html#setImportPathList)()和[QML Modules](index.htm#qml-modules)。 ``` QDeclarativeEngine.addPluginPath (self, QString?dir) ``` 添加_path_因為此時發動機搜索的導入模塊本地插件(在引用的目錄`qmldir`文件) 。 默認情況下,列表中只包含`.`即在該目錄中的引擎的搜索`qmldir`文件本身。 新添加的_path_將首先在[pluginPathList](qdeclarativeengine.html#pluginPathList)( ) 。 **See also** [setPluginPathList](qdeclarativeengine.html#setPluginPathList)( ) 。 ``` QUrl QDeclarativeEngine.baseUrl (self) ``` [](qurl.html) [返回的基礎URL為這個引擎。基本URL僅用于解決組件時的相對URL被傳遞給](qurl.html)[QDeclarativeComponent](qdeclarativecomponent.html)構造函數。 如果基URL尚未顯式設置,則此方法返回應用程序的當前工作目錄。 **See also** [setBaseUrl](qdeclarativeengine.html#setBaseUrl)( ) 。 ``` QDeclarativeEngine.clearComponentCache (self) ``` 清除發動機的內部部件緩存。 通常情況下,[QDeclarativeEngine](qdeclarativeengine.html)緩存從QML文件中加載的組件。這種方法清除該緩存,并強制組件重新加載。 ``` QDeclarativeContext QDeclarativeEngine.contextForObject (QObject) ``` [](qdeclarativecontext.html) [返回](qdeclarativecontext.html)[QDeclarativeContext](qdeclarativecontext.html)為_object_,或者0,如果沒有上下文已定。 當[QDeclarativeEngine](qdeclarativeengine.html)實例化一個[QObject](qobject.html)時,上下文被自動設置。 **See also** [setContextForObject](qdeclarativeengine.html#setContextForObject)( ) 。 ``` QDeclarativeImageProvider QDeclarativeEngine.imageProvider (self, QString?id) ``` [](qdeclarativeimageprovider.html) [返回](qdeclarativeimageprovider.html)[QDeclarativeImageProvider](qdeclarativeimageprovider.html)對于設置_providerId_。 ``` QStringList QDeclarativeEngine.importPathList (self) ``` 返回將搜索引擎在一個基于URL的目錄結構安裝的模塊的目錄列表。 例如,如果`/opt/MyApp/lib/imports`在路徑中,然后QML的進口`com.mycompany.Feature`會導致[QDeclarativeEngine](qdeclarativeengine.html)看在`/opt/MyApp/lib/imports/com/mycompany/Feature/`對于由該模塊提供的組件。一`qmldir`文件是必需的,用于定義類型映射版本,并可能宣告擴展插件。 默認情況下,該列表包含應用程序的可執行文件的目錄,在指定路徑`QML_IMPORT_PATH`環境變量,以及內置的`ImportsPath`從[QLibraryInfo](qlibraryinfo.html)。 **See also** [addImportPath](qdeclarativeengine.html#addImportPath)()和[setImportPathList](qdeclarativeengine.html#setImportPathList)( ) 。 ``` (bool, QString?errorString) QDeclarativeEngine.importPlugin (self, QString?filePath, QString?uri) ``` 進口評為插件_filePath_與_uri_提供。返回True如果插件被成功導入,否則返回False 。 如果失敗,如果非空, *_errorString_將被設置為描述失敗的消息。 該插件必須是Qt的插件,它實現了[QDeclarativeExtensionPlugin](qdeclarativeextensionplugin.html)接口。 ``` QNetworkAccessManager QDeclarativeEngine.networkAccessManager (self) ``` [](qnetworkaccessmanager.html) [返回一個共同的](qnetworkaccessmanager.html)[QNetworkAccessManager](qnetworkaccessmanager.html)它可以用來由本機實例化的任何QML元素。 如果[QDeclarativeNetworkAccessManagerFactory](qdeclarativenetworkaccessmanagerfactory.html)已被設置和一[QNetworkAccessManager](qnetworkaccessmanager.html)尚未建立,則[QDeclarativeNetworkAccessManagerFactory](qdeclarativenetworkaccessmanagerfactory.html)將被用來創建[QNetworkAccessManager](qnetworkaccessmanager.html)否則返回[QNetworkAccessManager](qnetworkaccessmanager.html)不會有任何代理或緩存設置。 **See also** [setNetworkAccessManagerFactory](qdeclarativeengine.html#setNetworkAccessManagerFactory)( ) 。 ``` QDeclarativeNetworkAccessManagerFactory QDeclarativeEngine.networkAccessManagerFactory (self) ``` [](qdeclarativenetworkaccessmanagerfactory.html) [返回當前](qdeclarativenetworkaccessmanagerfactory.html)[QDeclarativeNetworkAccessManagerFactory](qdeclarativenetworkaccessmanagerfactory.html)。 **See also** [setNetworkAccessManagerFactory](qdeclarativeengine.html#setNetworkAccessManagerFactory)( ) 。 ``` ObjectOwnership QDeclarativeEngine.objectOwnership (QObject) ``` [ 返回的所有權_object_。 ](qdeclarativeengine.html#ObjectOwnership-enum) [**See also**](qdeclarativeengine.html#ObjectOwnership-enum) [setObjectOwnership](qdeclarativeengine.html#setObjectOwnership)( ) 。 ``` QString QDeclarativeEngine.offlineStoragePath (self) ``` ``` bool QDeclarativeEngine.outputWarningsToStandardError (self) ``` 返回True如果警告信息將被輸出到stderr除了由正在發射[warnings](qdeclarativeengine.html#warnings)( )信號,否則為False 。 默認值是True 。 **See also** [setOutputWarningsToStandardError](qdeclarativeengine.html#setOutputWarningsToStandardError)( ) 。 ``` QStringList QDeclarativeEngine.pluginPathList (self) ``` 返回目錄所在的搜索引擎為進口原生模塊插件(在引用的列表`qmldir`文件) 。 默認情況下,列表中只包含`.`即在該目錄中的引擎的搜索`qmldir`文件本身。 **See also** [addPluginPath](qdeclarativeengine.html#addPluginPath)()和[setPluginPathList](qdeclarativeengine.html#setPluginPathList)( ) 。 ``` QDeclarativeEngine.removeImageProvider (self, QString?id) ``` 移除[QDeclarativeImageProvider](qdeclarativeimageprovider.html)為_providerId_。 返回,如果它被發現的提供者,否則返回0 。 **See also** [addImageProvider](qdeclarativeengine.html#addImageProvider)( ) 。 ``` QDeclarativeContext QDeclarativeEngine.rootContext (self) ``` [ 返回引擎的根上下文。 ](qdeclarativecontext.html) [根上下文是由自動創建](qdeclarativecontext.html)[QDeclarativeEngine](qdeclarativeengine.html)。數據應提供給由發動機實例化所有的QML組件實例應該放在根上下文。 額外的數據應該只提供給組件實例的一個子集應該被添加到子上下文父到根上下文。 ``` QDeclarativeEngine.setBaseUrl (self, QUrl) ``` 設置這臺發動機的基礎URL_url_。 **See also** [baseUrl](qdeclarativeengine.html#baseUrl)( ) 。 ``` QDeclarativeEngine.setContextForObject (QObject, QDeclarativeContext) ``` 設置[QDeclarativeContext](qdeclarativecontext.html)為_object_至_context_。如果_object_已經有一個上下文,則輸出警告,但上下文不被改變。 當[QDeclarativeEngine](qdeclarativeengine.html)實例化一個[QObject](qobject.html)時,上下文被自動設置。 **See also** [contextForObject](qdeclarativeengine.html#contextForObject)( ) 。 ``` QDeclarativeEngine.setImportPathList (self, QStringList?paths) ``` Sets _paths_因為那里的搜索引擎在一個基于URL的目錄結構安裝的模塊的目錄列表。 默認情況下,該列表包含應用程序的可執行文件的目錄,在指定路徑`QML_IMPORT_PATH`環境變量,以及內置的`ImportsPath`從[QLibraryInfo](qlibraryinfo.html)。 **See also** [importPathList](qdeclarativeengine.html#importPathList)()和[addImportPath](qdeclarativeengine.html#addImportPath)( ) 。 ``` QDeclarativeEngine.setNetworkAccessManagerFactory (self, QDeclarativeNetworkAccessManagerFactory) ``` 設置_factory_用于創建[QNetworkAccessManager](qnetworkaccessmanager.html)(S ) 。 [QNetworkAccessManager](qnetworkaccessmanager.html)用于通過QML所有網絡訪問。通過實現工廠能夠創建自定義[QNetworkAccessManager](qnetworkaccessmanager.html)有專門的緩存,代理和cookie支持。 工廠必須執行引擎之前進行設置。 **See also** [networkAccessManagerFactory](qdeclarativeengine.html#networkAccessManagerFactory)( ) 。 ``` QDeclarativeEngine.setObjectOwnership (QObject, ObjectOwnership) ``` 設置_ownership_的_object_。 **See also** [objectOwnership](qdeclarativeengine.html#objectOwnership)( ) 。 ``` QDeclarativeEngine.setOfflineStoragePath (self, QString?dir) ``` ``` QDeclarativeEngine.setOutputWarningsToStandardError (self, bool) ``` 設置是否警告信息將被輸出到stderr到_enabled_。 If _enabled_誠然,通過QML產生的任何警告信息將被輸出到標準錯誤,并發射[warnings](qdeclarativeengine.html#warnings)()信號。如果_enabled_是假的,對[warnings](qdeclarativeengine.html#warnings)()信號將被發射。這允許應用程序來處理報警輸出自己。 默認值是True 。 **See also** [outputWarningsToStandardError](qdeclarativeengine.html#outputWarningsToStandardError)( ) 。 ``` QDeclarativeEngine.setPluginPathList (self, QStringList?paths) ``` 設置目錄所在的引擎搜索的導入模塊本地插件(在引用的列表`qmldir`文件)_paths_。 默認情況下,列表中只包含`.`即在該目錄中的引擎的搜索`qmldir`文件本身。 **See also** [pluginPathList](qdeclarativeengine.html#pluginPathList)()和[addPluginPath](qdeclarativeengine.html#addPluginPath)( ) 。 * * * ## Qt Signal Documentation ``` void quit () ``` 這是該信號的默認超載。 這個信號被發射時,由發動機加載的QML想退出。 ``` void warnings (const QList<QDeclarativeError>&) ``` 這是該信號的默認超載。 這個信號被發射時_warnings_通過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>

                              哎呀哎呀视频在线观看