<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # QDeclarativeContext Class Reference ## [[QtDeclarative](index.htm) module] 該QDeclarativeContext類定義中的QML引擎的內容。[More...](#details) 繼承[QObject](qobject.html)。 ### Methods * `__init__ (self, QDeclarativeEngine?engine, QObject?parent?=?None)` * `__init__ (self, QDeclarativeContext?context, QObject?parent?=?None)` * `QUrl baseUrl (self)` * `QObject contextObject (self)` * `QVariant contextProperty (self, QString)` * `QDeclarativeEngine engine (self)` * `bool isValid (self)` * `QDeclarativeContext parentContext (self)` * `QUrl resolvedUrl (self, QUrl)` * `setBaseUrl (self, QUrl)` * `setContextObject (self, QObject)` * `setContextProperty (self, QString, QObject)` * `setContextProperty (self, QString, QVariant)` * * * ## Detailed Description 該QDeclarativeContext類定義中的QML引擎的內容。 上下文允許數據被暴露在由QML引擎實例化的QML組件。 每個QDeclarativeContext包含的一組屬性,其獨特的[QObject](qobject.html)性質,即允許數據被明確地通過名稱綁定到上下文。上下文屬性都通過調用定義和更新[QDeclarativeContext.setContextProperty](qdeclarativecontext.html#setContextProperty)( ) 。下面的例子顯示了Qt的模型被綁定到一個上下文,然后從一個QML文件的訪問。 ``` [QDeclarativeEngine](qdeclarativeengine.html) engine; [QStringListModel](qstringlistmodel.html) modelData; QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); context->setContextProperty("myModel", &modelData); [QDeclarativeComponent](qdeclarativecomponent.html) component(&engine); component.setData("import QtQuick 1.0\nListView { model: myModel }", [QUrl](qurl.html)()); [QObject](qobject.html) *window = component.create(context); ``` 注意它是創作者將其刪除構建任何QDeclarativeContext責任。如果`context`在本例中的對象不再需要時`window`組件實例被破壞,`context`必須顯式地銷毀。確保這一點的最簡單的方法是設置`window`作為父`context`。 為了簡化綁定和維護更大的數據集,一個上下文對象可以在QDeclarativeContext進行設置。是上下文對象的所有屬性可通過名稱的背景下,彷彿他們都分別通過調用添加[QDeclarativeContext.setContextProperty](qdeclarativecontext.html#setContextProperty)( ) 。通過屬性的通知信號被檢測到更改屬性的值。設置一個上下文對象是速度更快,比手動添加和維修器材上下文屬性值更容易。 下面的例子中有相同的效果與前面的一個,但是它使用了一個上下文對象。 ``` class MyDataSet : ... { ... Q_PROPERTY([QAbstractItemModel](qabstractitemmodel.html) *myModel READ model NOTIFY modelChanged) ... }; MyDataSet myDataSet; [QDeclarativeEngine](qdeclarativeengine.html) engine; QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); context->setContextObject(&myDataSet); [QDeclarativeComponent](qdeclarativecomponent.html) component(&engine); component.setData("import QtQuick 1.0\nListView { model: myModel }", [QUrl](qurl.html)()); component.create(context); ``` 通過明確添加的所有屬性[QDeclarativeContext.setContextProperty](qdeclarativecontext.html#setContextProperty)( )優先于上下文對象的屬性。 #### The Context Hierarchy 上下文可以形成一個分層結構。這個層次結構的根是QML引擎的[root context](qdeclarativeengine.html#rootContext)。兒童上下文繼承父母的上下文屬性,如果一個孩子的上下文設置已經存在于它的父上下文屬性,新的上下文屬性將復蓋母公司。 下面的示例定義兩個上下文 - `context1`和`context2`。第二個方面復蓋從先用一個新值繼承了“b”的內容屬性。 ``` [QDeclarativeEngine](qdeclarativeengine.html) engine; QDeclarativeContext *context1 = new QDeclarativeContext(engine.rootContext()); QDeclarativeContext *context2 = new QDeclarativeContext(context1); context1->setContextProperty("a", 12); context1->setContextProperty("b", 12); context2->setContextProperty("b", 15); ``` 而在實例化一個上下文QML對象不嚴格的情況下擁有的,綁定。如果上下文被銷毀,優秀的QML對象的屬性綁定將停止評估。 **Warning:**設置上下文對象或之后有物體在這種情況下被創建增加新的內容屬性是一個昂貴的操作(實際上是強迫所有綁定重新評估) 。因此,只要有可能,你應該使用它來創建任何對象之前完成上下文的“設置” 。 * * * ## Method Documentation ``` QDeclarativeContext.__init__ (self, QDeclarativeEngine?engine, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建一個新的[QDeclarativeContext](qdeclarativecontext.html)作為一個子_engine_的根上下文,以及[QObject](qobject.html) _parent_。 ``` QDeclarativeContext.__init__ (self, QDeclarativeContext?context, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 創建一個新的[QDeclarativeContext](qdeclarativecontext.html)用給定的_parentContext_和[QObject](qobject.html) _parent_。 ``` QUrl QDeclarativeContext.baseUrl (self) ``` [ 返回組件的基本URL ,或含有成分,如果沒有被設置。 ](qurl.html) [**See also**](qurl.html) [setBaseUrl](qdeclarativecontext.html#setBaseUrl)( ) 。 ``` QObject QDeclarativeContext.contextObject (self) ``` [ 返回上下文對象,或0 ,如果沒有上下文對象。 ](qobject.html) [**See also**](qobject.html) [setContextObject](qdeclarativecontext.html#setContextObject)( ) 。 ``` QVariant QDeclarativeContext.contextProperty (self, QString) ``` 返回的值_name_屬性這方面的[QVariant](qvariant.html)。 **See also** [setContextProperty](qdeclarativecontext.html#setContextProperty)( ) 。 ``` QDeclarativeEngine QDeclarativeContext.engine (self) ``` [](qdeclarativeengine.html) [返回上下文的](qdeclarativeengine.html)[QDeclarativeEngine](qdeclarativeengine.html),或者0,如果上下文沒有[QDeclarativeEngine](qdeclarativeengine.html)或[QDeclarativeEngine](qdeclarativeengine.html)被摧毀。 ``` bool QDeclarativeContext.isValid (self) ``` 返回上下文是否有效。 是有效的,上下文必須有一個發動機,它的[contextObject](qdeclarativecontext.html#contextObject)() ,如果有的話,必須沒有被刪除。 ``` QDeclarativeContext QDeclarativeContext.parentContext (self) ``` [](qdeclarativecontext.html) [返回上下文的父](qdeclarativecontext.html)[QDeclarativeContext](qdeclarativecontext.html),或者0,如果這方面沒有父或父已被破壞。 ``` QUrl QDeclarativeContext.resolvedUrl (self, QUrl) ``` [ 解析URL_src_相對于包含組件的URL 。 ](qurl.html) [**See also**](qurl.html) [QDeclarativeEngine.baseUrl](qdeclarativeengine.html#baseUrl)()和[setBaseUrl](qdeclarativecontext.html#setBaseUrl)( ) 。 ``` QDeclarativeContext.setBaseUrl (self, QUrl) ``` 顯式設置的URL[resolvedUrl](qdeclarativecontext.html#resolvedUrl)( )將使用相對引用_baseUrl_。 調用此函數將復蓋默認使用的含有成分的url 。 **See also** [baseUrl](qdeclarativecontext.html#baseUrl)()和[resolvedUrl](qdeclarativecontext.html#resolvedUrl)( ) 。 ``` QDeclarativeContext.setContextObject (self, QObject) ``` 設置上下文_object_。 **See also** [contextObject](qdeclarativecontext.html#contextObject)( ) 。 ``` QDeclarativeContext.setContextProperty (self, QString, QObject) ``` 設置_value_的_name_財產這方面。 [QDeclarativeContext](qdeclarativecontext.html)不**not**取得其所有權_value_。 **See also** [contextProperty](qdeclarativecontext.html#contextProperty)( ) 。 ``` QDeclarativeContext.setContextProperty (self, QString, QVariant) ``` 設置的_value_的_name_財產這方面。
                  <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>

                              哎呀哎呀视频在线观看