<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之旅 廣告
                # QDeclarativeComponent Class Reference ## [[QtDeclarative](index.htm) module] 該QDeclarativeComponent類封裝了QML組件定義。[More...](#details) 繼承[QObject](qobject.html)。 ### Types * `enum Status { Null, Ready, Loading, Error }` ### Methods * `__init__ (self, QDeclarativeEngine, QObject?parent?=?None)` * `__init__ (self, QDeclarativeEngine, QString?fileName, QObject?parent?=?None)` * `__init__ (self, QDeclarativeEngine, QUrl?url, QObject?parent?=?None)` * `QObject beginCreate (self, QDeclarativeContext)` * `completeCreate (self)` * `QObject create (self, QDeclarativeContext?context?=?None)` * `QDeclarativeContext creationContext (self)` * `list-of-QDeclarativeError errors (self)` * `bool isError (self)` * `bool isLoading (self)` * `bool isNull (self)` * `bool isReady (self)` * `loadUrl (self, QUrl?url)` * `float progress (self)` * `setData (self, QByteArray, QUrl?baseUrl)` * `Status status (self)` * `QUrl url (self)` ### Qt Signals * `void progressChanged (qreal)` * `void statusChanged (QDeclarativeComponent::Status)` * * * ## Detailed Description 該QDeclarativeComponent類封裝了QML組件定義。 組件是可重用的,封裝QML元素具有定義良好的接口。他們往往在定義[Component Files](index.htm)。 一個QDeclarativeComponent實例可以從QML文件中創建。例如,如果有一個`main.qml`文件是這樣的: ``` import QtQuick 1.0 [Item](index.htm) { width: 200 height: 200 } ``` 下面的代碼加載這個QML文件作為一個組件,使用創建該組件的一個實例[create](qdeclarativecomponent.html#create)( ) ,然后查詢[Item](index.htm)的[width](index.htm#width-prop)價值: ``` [QDeclarativeEngine](qdeclarativeengine.html) *engine = new [QDeclarativeEngine](qdeclarativeengine.html); QDeclarativeComponent component(engine, [QUrl](qurl.html).fromLocalFile("main.qml")); [QObject](qobject.html) *myObject = component.create(); [QDeclarativeItem](qdeclarativeitem.html) *item = qobject_cast<[QDeclarativeItem](qdeclarativeitem.html)*>(myObject); int width = item->width(); // width = 200 ``` #### Network Components 如果傳遞給QDeclarativeComponent URL是一個網絡資源,或者QML文檔引用的網絡資源,將QDeclarativeComponent具有獲取網絡數據之前,它能夠創建對象。在這種情況下, QDeclarativeComponent將有[Loading](qdeclarativecomponent.html#Status-enum) [status](qdeclarativecomponent.html#status-prop)。應用程序將不得不等待,直到該組件是[Ready](qdeclarativecomponent.html#Status-enum)打電話之前[QDeclarativeComponent.create](qdeclarativecomponent.html#create)( ) 。 下面的示例演示如何加載從網絡資源中的QML文件。創建QDeclarativeComponent后,它測試組件是否被加載。如果是,它連接到[QDeclarativeComponent.statusChanged](qdeclarativecomponent.html#statusChanged)( )信號,否則調用`continueLoading()`方法直接。需要注意的是[QDeclarativeComponent.isLoading](qdeclarativecomponent.html#isLoading)( )可能是假的網絡組件,如果該組件已被緩存,并立即準備就緒。 ``` MyApplication.MyApplication() { // ... component = new QDeclarativeComponent(engine, [QUrl](qurl.html)("http://www.example.com/main.qml")); if (component->isLoading()) [QObject](qobject.html).connect(component, SIGNAL(statusChanged(QDeclarativeComponent.Status)), this, SLOT(continueLoading())); else continueLoading(); } void MyApplication.continueLoading() { if (component->isError()) { qWarning() << component->errors(); } else { [QObject](qobject.html) *myObject = component->create(); } } ``` * * * ## Type Documentation ``` QDeclarativeComponent.Status ``` 指定的加載狀態[QDeclarativeComponent](qdeclarativecomponent.html)。 | Constant | Value | Description | | --- | --- | --- | | `QDeclarativeComponent.Null` | `0` | This [QDeclarativeComponent](qdeclarativecomponent.html)沒有數據。通話[loadUrl](qdeclarativecomponent.html#loadUrl)()或[setData](qdeclarativecomponent.html#setData)()添加QML內容。 | | `QDeclarativeComponent.Ready` | `1` | This [QDeclarativeComponent](qdeclarativecomponent.html)準備就緒,[create](qdeclarativecomponent.html#create)( )可以被調用。 | | `QDeclarativeComponent.Loading` | `2` | This [QDeclarativeComponent](qdeclarativecomponent.html)正在加載網絡數據。 | | `QDeclarativeComponent.Error` | `3` | 發生了錯誤。通話[errors](qdeclarativecomponent.html#errors)( )來獲取{列表[QDeclarativeError](qdeclarativeerror.html){ } }錯誤。 | * * * ## Method Documentation ``` QDeclarativeComponent.__init__ (self, QDeclarativeEngine, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建[QDeclarativeComponent](qdeclarativecomponent.html)沒有數據,并給它指定_engine_和_parent_。與設定的數據[setData](qdeclarativecomponent.html#setData)( ) 。 ``` QDeclarativeComponent.__init__ (self, QDeclarativeEngine, QString?fileName, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 ``` QDeclarativeComponent.__init__ (self, QDeclarativeEngine, QUrl?url, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建[QDeclarativeComponent](qdeclarativecomponent.html)從給定的_fileName_并給它指定_parent_和_engine_。 **See also** [loadUrl](qdeclarativecomponent.html#loadUrl)( ) 。 ``` QObject QDeclarativeComponent.beginCreate (self, QDeclarativeContext) ``` [](qobject.html) [這種方法提供了更高級的控制組件實例的創建。一般情況下,程序員應該使用](qobject.html)[QDeclarativeComponent.create](qdeclarativecomponent.html#create)()來創建一個組件。 此組件創建一個對象實例。返回0,如果創建失敗。_context_指定一個要在其中創建對象實例的上下文。 When [QDeclarativeComponent](qdeclarativecomponent.html)構造一個實例,它發生在三個步驟: 1. 對象層次被創建,并且常數值分配。 2. 物業綁定進行評估的第一次。 3. 如果適用,[QDeclarativeParserStatus.componentComplete](qdeclarativeparserstatus.html#componentComplete)()被調用的對象。 QDeclarativeComponent.beginCreate ( )不同于[QDeclarativeComponent.create](qdeclarativecomponent.html#create)() ,因為它僅執行步驟1 。[QDeclarativeComponent.completeCreate](qdeclarativecomponent.html#completeCreate)( )必須被調用來完成步驟2和3 。 使用附加屬性時,將信息傳達給一個實例化的組件,因為它可以讓它們的初始值進行配置之前,物業綁定生效,這突破點有時是有用的。 ``` QDeclarativeComponent.completeCreate (self) ``` 這種方法提供了更高級的控制組件實例的創建。一般情況下,程序員應該使用[QDeclarativeComponent.create](qdeclarativecomponent.html#create)()來創建一個組件。 完成組件創建開始[QDeclarativeComponent.beginCreate](qdeclarativecomponent.html#beginCreate)( ) 。 ``` QObject QDeclarativeComponent.create (self, QDeclarativeContext?context?=?None) ``` [ 此組件創建一個對象實例。返回0,如果創建失敗。_context_指定一個要在其中創建對象實例的上下文。 ](qobject.html) [If _context_為0 (默認值) ,它會在引擎的創建實例](qobject.html)[root context](qdeclarativeengine.html#rootContext)。 ``` QDeclarativeContext QDeclarativeComponent.creationContext (self) ``` [](qdeclarativecontext.html) [返回](qdeclarativecontext.html)[QDeclarativeContext](qdeclarativecontext.html)該組件被創建。這是僅適用于直接從QML創建的組件。 ``` list-of-QDeclarativeError QDeclarativeComponent.errors (self) ``` 返回的最后一個編譯期間發生的錯誤的列表或創建操作。如果返回空列表[isError](qdeclarativecomponent.html#isError)( )未設置。 ``` bool QDeclarativeComponent.isError (self) ``` 返回True如果[status](qdeclarativecomponent.html#status-prop)()==[QDeclarativeComponent.Error](qdeclarativecomponent.html#Status-enum)。 ``` bool QDeclarativeComponent.isLoading (self) ``` 返回True如果[status](qdeclarativecomponent.html#status-prop)()==[QDeclarativeComponent.Loading](qdeclarativecomponent.html#Status-enum)。 ``` bool QDeclarativeComponent.isNull (self) ``` 返回True如果[status](qdeclarativecomponent.html#status-prop)()==[QDeclarativeComponent.Null](qdeclarativecomponent.html#Status-enum)。 ``` bool QDeclarativeComponent.isReady (self) ``` 返回True如果[status](qdeclarativecomponent.html#status-prop)()==[QDeclarativeComponent.Ready](qdeclarativecomponent.html#Status-enum)。 ``` QDeclarativeComponent.loadUrl (self, QUrl?url) ``` 加載[QDeclarativeComponent](qdeclarativecomponent.html)從所提供的_url_。 確保所提供的URL是充分和正確的,尤其是借[QUrl.fromLocalFile](qurl.html#fromLocalFile)( )裝載從本地文件系統中的文件時。 ``` float QDeclarativeComponent.progress (self) ``` ``` QDeclarativeComponent.setData (self, QByteArray, QUrl?baseUrl) ``` 設置[QDeclarativeComponent](qdeclarativecomponent.html)使用給定的QML_data_。如果_url_被提供,它是用來設置該組件的名稱和提供一個基本路徑由該元件得到解決的項目。 ``` Status QDeclarativeComponent.status (self) ``` [](qdeclarativecomponent.html#Status-enum) ``` QUrl QDeclarativeComponent.url (self) ``` [ * * * ## Qt Signal Documentation ``` void progressChanged (qreal) ``` 這是該信號的默認超載。 每當發射組件的加載進度的變化。_progress_將介于0.0 (無負載)和1.0 (成品)目前的進展。 ``` void statusChanged (QDeclarativeComponent::Status) ``` 這是該信號的默認超載。 每當發射組件的狀態變化。_status_將新的狀態。 ](qurl.html)
                  <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>

                              哎呀哎呀视频在线观看