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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # QDeclarativeImageProvider Class Reference ## [[QtDeclarative](index.htm) module] 該QDeclarativeImageProvider類提供支持像素圖和螺紋圖像請求在QML的接口。[More...](#details) ### Types * `enum ImageType { Image, Pixmap }` ### Methods * `__init__ (self, ImageType?type)` * `__init__ (self, QDeclarativeImageProvider)` * `ImageType imageType (self)` * `QImage requestImage (self, QString?id, QSize?size, QSize?requestedSize)` * `QPixmap requestPixmap (self, QString?id, QSize?size, QSize?requestedSize)` * * * ## Detailed Description 該QDeclarativeImageProvider類提供支持像素圖和螺紋圖像請求在QML的接口。 QDeclarativeImageProvider是用來提供在QML應用先進的圖像加載功能。它允許在QML圖像是: * Loaded using QPixmaps rather than actual image files * Loaded asynchronously in a separate thread, if [imageType](qdeclarativeimageprovider.html#imageType)() is [ImageType.Image](qdeclarativeimageprovider.html#ImageType-enum) 要指定圖像應該通過圖像提供商加載,使用**"image:"**方案的圖像的URL源,接著通過圖像提供者和請求圖像的標識符。例如: ``` [Image](qdeclarativeimageprovider.html#ImageType-enum) { source: "image://myimageprovider/image.png" } ``` 這指定圖像應該由名為“ myimageprovider ”的形象提供商被加載,并且要加載的圖像被命名為“ image.png ” 。根據已通過注冊的供應商的QML引擎調用相應的圖像提供商[QDeclarativeEngine.addImageProvider](qdeclarativeengine.html#addImageProvider)( ) 。 請注意,標識符是不區分大小寫的,但是URL的其馀部分將被傳遞與保存情況。例如,下面的代碼片段仍然會指定的圖像是由一個名為“ myimageprovider ”的形象提供加載,但它會要求不同的圖像比上面的代碼片段( “ Image.png ”而不是“ image.png ” ) 。 ``` [Image](qdeclarativeimageprovider.html#ImageType-enum) { source: "image://MyImageProvider/Image.png" } ``` 如果你想要的URL的其馀部分是不區分大小寫的,你將不得不采取的是自己的形象提供商內部的照顧。 #### An example 這里有兩個圖像。他們的`source`值表明它們應以命名為“顏色”的圖像提供者被加載,并且要加載的圖像是“黃色”和“紅色” ,分別是: ``` [Column](index.htm) { [Image](qdeclarativeimageprovider.html#ImageType-enum) { source: "image://colors/yellow" } [Image](qdeclarativeimageprovider.html#ImageType-enum) { source: "image://colors/red" } } ``` 當這些圖像通過QML加載,它會尋找一個匹配的圖像提供者和調用它的[requestImage](qdeclarativeimageprovider.html#requestImage)()或[requestPixmap](qdeclarativeimageprovider.html#requestPixmap)()方法(取決于其[imageType](qdeclarativeimageprovider.html#imageType)())來加載圖像。該方法被調用的`id`參數設置為“黃色”的第一映像,而“紅色”為第二。 這里是一個圖像提供商實現,可以加載由上面的QML要求的圖像。此實現動態生成[QPixmap](qpixmap.html)那充滿了請求的彩色圖像: ``` class ColorImageProvider : public QDeclarativeImageProvider { public: ColorImageProvider() : QDeclarativeImageProvider(QDeclarativeImageProvider.Pixmap) { } [QPixmap](qpixmap.html) requestPixmap(const [QString](qstring.html) &id, [QSize](qsize.html) *size, const [QSize](qsize.html) &requestedSize) { int width = 100; int height = 50; if (size) *size = [QSize](qsize.html)(width, height); [QPixmap](qpixmap.html) pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, requestedSize.height() > 0 ? requestedSize.height() : height); pixmap.fill([QColor](qcolor.html)(id).rgba()); return pixmap; } }; ``` 為了使這提供商訪問QML ,它注冊到QML引擎與“色”的標識符: ``` int main(int argc, char *argv[]) { ... [QDeclarativeEngine](qdeclarativeengine.html) engine; engine->addImageProvider(QLatin1String("colors"), new ColorPixmapProvider); ... } ``` 現在,該圖像可以成功加載在QML : ![](https://img.kancloud.cn/48/5d/485d0989bb5ad297ec66fb0a7d844ac6_96x97.png) 一個完整的例子可在Qt的[examples/declarative/cppextensions/imageprovider](index.htm)目錄。請注意該示例通過一個注冊的供應商[plugin](qdeclarativeextensionplugin.html)而不是注冊在應用程序中`main()`功能,如上所示。 #### Asynchronous image loading 支持圖片提供商[QImage](qimage.html)自動加載包括對圖像的異步加載的支持。要啟用異步加載的圖像源,設置`asynchronous`屬性為`true`的相關[Image](qdeclarativeimageprovider.html#ImageType-enum),[BorderImage](index.htm) or [AnimatedImage](index.htm)對象。當啟用此功能時,圖像請求提供商是運行在一個低優先級的線程,讓圖像加載在后臺被執行,并且減少了用戶界面的性能影響。 不支持,提供圖像提供商異步加載[QPixmap](qpixmap.html)而不是[QImage](qimage.html)值,像素映射只能在主線程中創建的。在這種情況下,如果[asynchronous](index.htm#asynchronous-prop)被設置為`true`,該值將被忽略和圖像同步加載。 #### Image caching 由QDeclarativeImageProvider返回圖像會自動緩存,類似于由QML引擎加載任何圖像。當用“圖像:/ / ”前綴的圖像被從緩存中加載,[requestImage](qdeclarativeimageprovider.html#requestImage)()和[requestPixmap](qdeclarativeimageprovider.html#requestPixmap)( )不會被調用相關圖像提供商。如果圖像應始終從圖像提供者獲取,并且不應該在所有高速緩存中,設置`cache`屬性為`false`的相關[Image](qdeclarativeimageprovider.html#ImageType-enum),[BorderImage](index.htm) or [AnimatedImage](index.htm)對象。 * * * ## Type Documentation ``` QDeclarativeImageProvider.ImageType ``` 定義此圖像提供商支持的圖像類型。 | Constant | Value | Description | | --- | --- | --- | | `QDeclarativeImageProvider.Image` | `0` | 圖像提供商提供[QImage](qimage.html)圖像。該[requestImage](qdeclarativeimageprovider.html#requestImage)( )方法會被調用所有的圖像請求。 | | `QDeclarativeImageProvider.Pixmap` | `1` | 圖像提供商提供[QPixmap](qpixmap.html)圖像。該[requestPixmap](qdeclarativeimageprovider.html#requestPixmap)( )方法會被調用所有的圖像請求。 | * * * ## Method Documentation ``` QDeclarativeImageProvider.__init__ (self, ImageType?type) ``` 創建一個圖像提供商,將提供給定的圖像_type_。 ``` QDeclarativeImageProvider.__init__ (self, QDeclarativeImageProvider) ``` ``` ImageType QDeclarativeImageProvider.imageType (self) ``` [ 返回此提供程序支持的圖像類型。 ](qdeclarativeimageprovider.html#ImageType-enum) ``` QImage QDeclarativeImageProvider.requestImage (self, QString?id, QSize?size, QSize?requestedSize) ``` [ 實現此方法與返回的圖像_id_。默認實現返回一個空的圖像。 ](qimage.html) [該_id_是請求的圖像源,以“形象: ”方案和提供商的標識去掉。例如,如果圖像](qimage.html)[source](index.htm#source-prop)在“圖像:/ / MYPROVIDER /圖標/家” ,給定的_id_將“圖標/家” 。 該_requestedSize_對應于[Image.sourceSize](index.htm#sourceSize-prop)通過圖像元素要求。如果_requestedSize_是一個有效的大小,返回的圖像應該是大小。 在所有情況下,_size_必須被設置到圖像的原始大小。這是用于設置[width](index.htm#width-prop)和[height](index.htm#height-prop)相關的[Image](qdeclarativeimageprovider.html#ImageType-enum)如果這些值沒有顯式設置。 **Note:**這種方法可以被多個線程調用,因此確保該方法的實現是可重入的。 ``` QPixmap QDeclarativeImageProvider.requestPixmap (self, QString?id, QSize?size, QSize?requestedSize) ``` [ 實現此方法與返回的像素圖_id_。默認實現返回一個空的像素圖。 ](qpixmap.html) [該_id_是請求的圖像源,以“形象: ”方案和提供商的標識去掉。例如,如果圖像](qpixmap.html)[source](index.htm#source-prop)在“圖像:/ / MYPROVIDER /圖標/家” ,給定的_id_將“圖標/家” 。 該_requestedSize_對應于[Image.sourceSize](index.htm#sourceSize-prop)通過圖像元素要求。如果_requestedSize_是一個有效的大小,返回的圖像應該是大小。 在所有情況下,_size_必須被設置到圖像的原始大小。這是用于設置[width](index.htm#width-prop)和[height](index.htm#height-prop)相關的[Image](qdeclarativeimageprovider.html#ImageType-enum)如果這些值沒有顯式設置。
                  <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>

                              哎呀哎呀视频在线观看