• <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 閱讀(955) 評論(0)  編輯 收藏 引用 所屬分類: QT編程
             
            国产精品禁18久久久夂久| 91久久精品电影| 亚洲av日韩精品久久久久久a| 日产精品久久久一区二区| 中文字幕人妻色偷偷久久 | 成人国内精品久久久久影院VR| 国色天香久久久久久久小说| 天天爽天天狠久久久综合麻豆| 国产精品久久久久aaaa| 99久久精品免费看国产免费| 久久亚洲精品无码播放| 亚洲国产欧美国产综合久久| 久久99久久成人免费播放| 无码专区久久综合久中文字幕| 久久精品国产福利国产琪琪| 久久受www免费人成_看片中文| 精品久久久久久| 欧美久久久久久| 色综合久久88色综合天天| 亚洲狠狠婷婷综合久久久久| 国内精品伊人久久久久影院对白| 久久久噜噜噜www成人网| 久久这里有精品视频| 久久精品麻豆日日躁夜夜躁| 久久精品亚洲AV久久久无码| 精品久久久久久久中文字幕| 久久免费小视频| 国产精品一区二区久久国产| 午夜欧美精品久久久久久久| 综合久久给合久久狠狠狠97色 | www亚洲欲色成人久久精品| 午夜人妻久久久久久久久| 日韩电影久久久被窝网| 国产精品欧美久久久久无广告| 久久国产高清字幕中文| 色综合久久久久综合体桃花网| 一极黄色视频久久网站| 欧美日韩精品久久久久| 亚洲国产成人久久综合碰| 欧美成a人片免费看久久| 久久国产精品无|