• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            QML
            import QtQuick 2.2
            import QtQuick.Layouts 1.1
            import QtQuick.Controls 1.2

            Column 
            {
                width
            :640
                height:400
                
                Image 
                { 
                    id:image
                    width:640
                    cache: false
                    source: "image://colors/red" 
                
            }
                
                Connections
                
            {
                    target
            : imagecontext
                    onCallQmlRefeshImg:
                    {
                        image.source = ""
                        image.source = "image://imageprovider"
                        console.log("refresh.")
            ;
                    
            }
                }    
            }
            ImageProvider
            class ColorImageProvider : public QQuickImageProvider
            {
            public:
                ColorImageProvider()
                    : QQuickImageProvider(QQuickImageProvider::Pixmap)
                {
                }

                QPixmap requestPixmap(
            const QString &id, QSize *size, const QSize &requestedSize) override
                {
                    
            int width = 100;
                    
            int height = 50;

                    
            if (size)
                        
            *size = QSize(width, height);
                    QPixmap pixmap(requestedSize.width() 
            > 0 ? requestedSize.width() : width,
                        requestedSize.height() 
            > 0 ? requestedSize.height() : height);
                    pixmap.fill(QColor(id).rgba());
                    
            return pixmap;
                }
            };

            class ImageProvider : public QQuickImageProvider
            {
            public:
                ImageProvider::ImageProvider(ImageType type, Flags flags 
            = Flags()) :
                    QQuickImageProvider(type, flags)
                {
                }
                
                
            ~ImageProvider(){}

                QImage ImageProvider::requestImage(
            const QString &id, QSize *size, const QSize &requestedSize)
                {
                    
            return image;
                }

                QImage image;
            };

            ImageContext
            class ImageContext : public QObject
            {
                Q_OBJECT
            public:
                ImageContext(QObject
            * parent = 0);
                ImageProvider
            * m_imageProvider = nullptr;
            public slots:
                
            void setImage(const QImage& image);
            signals:
                
            void callQmlRefeshImg();
            };
            ImageContext::ImageContext(QObject* parent):
            QObject(parent)
            {
                m_imageProvider 
            = new ImageProvider(QQuickImageProvider::Image);
            }

            void ImageContext::setImage(const QImage& image)
            {
                m_imageProvider
            ->image = image;
                emit callQmlRefeshImg();
            }

            注冊和相應
                qml->engine()->addImageProvider(QLatin1String("colors"),new ColorImageProvider);
                ImageContext
            * context = new ImageContext(this);
                qml
            ->engine()->rootContext()->setContextProperty("imagecontext",context);
                qml
            ->engine()->addImageProvider(QLatin1String("imageprovider"),context->m_imageProvider);

                qml
            ->setSource(QUrl("image.qml"));

                QDir dir(
            "E:/MyVideoPlayer/Win32/Release/capture");

                QStringList files 
            = dir.entryList(QDir::Files,QDir::SortFlag::Time | QDir::SortFlag::Reversed);
                qDebug() 
            << "files:" << files.size();
                
                connect(button, 
            &QPushButton::clicked,[=]()
                   {
                       
            static int current = 0;
                       auto list 
            = qml->rootObject()->childItems();
                       
            if(current == files.size())
                           current 
            = 0;

                       QImage image;
                       QString file 
            = QString("E:/MyVideoPlayer/Win32/Release/capture/"+ files.at(current);
                       qDebug() 
            << "loaded:" << image.load(file) << "," << file<<","<<current;
                       context
            ->setImage(image);

                       current
            ++;
                   }
                );

            posted on 2019-08-05 11:37 ccsdu2009 閱讀(951) 評論(0)  編輯 收藏 引用 所屬分類: QT編程
             
            91精品国产91久久久久久蜜臀| 久久精品黄AA片一区二区三区| 久久精品国产亚洲av瑜伽| 精品国产热久久久福利| 久久热这里只有精品在线观看| 亚洲国产精品高清久久久| 久久久久高潮毛片免费全部播放| 国产69精品久久久久99| 伊人久久大香线蕉成人| 久久国产免费观看精品| 国产精品久久久久a影院| 青青草原综合久久| 精品国产99久久久久久麻豆| 国产一区二区精品久久凹凸| 一本久道久久综合狠狠爱| 久久久久国产视频电影| 2020最新久久久视精品爱| 性高湖久久久久久久久| 亚洲AⅤ优女AV综合久久久| 亚洲国产精品人久久| 国产∨亚洲V天堂无码久久久| 亚洲国产精品综合久久网络| 国产激情久久久久影院老熟女免费| 亚洲乱码精品久久久久..| 伊人色综合久久天天网| 婷婷久久综合九色综合九七| 99久久国产亚洲高清观看2024 | 亚洲AV无码久久寂寞少妇| 久久久久人妻精品一区三寸蜜桃 | 奇米综合四色77777久久| 欧美亚洲国产精品久久久久| 久久人人爽人人爽人人片AV麻豆| 久久久九九有精品国产| 国产精品18久久久久久vr| 97久久精品无码一区二区天美| 日本久久久久亚洲中字幕| 久久亚洲美女精品国产精品| 久久久久久久久无码精品亚洲日韩| 熟妇人妻久久中文字幕| 99久久人妻无码精品系列蜜桃| 国内精品久久久久久野外|