• <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編程
             
            亚洲国产成人精品久久久国产成人一区二区三区综 | 久久福利青草精品资源站| 久久综合给合久久狠狠狠97色69| 色综合久久久久综合体桃花网| 91精品国产色综合久久| 国产午夜精品理论片久久| 国产精品18久久久久久vr | 久久久久亚洲AV成人网人人网站| 久久久久无码精品| 国产综合久久久久| 久久精品这里只有精99品| 国产成人精品综合久久久| 久久99国产精品久久久| 一本一本久久a久久精品综合麻豆| 久久精品一区二区三区AV| 久久综合丁香激情久久| 伊人热热久久原色播放www| 精品少妇人妻av无码久久| 蜜桃麻豆www久久国产精品| 国内精品久久久久影院优| 欧美午夜A∨大片久久 | 久久久久亚洲精品男人的天堂| 久久久久高潮综合影院| 久久久久国色AV免费观看| 久久久久久九九99精品| 久久国语露脸国产精品电影| 日韩精品国产自在久久现线拍| 亚洲精品无码久久久久久| 色综合久久88色综合天天 | 丁香五月综合久久激情| 精品永久久福利一区二区| 久久久久亚洲精品日久生情| 久久国产免费直播| 国产精品美女久久久久av爽| 99热热久久这里只有精品68| 97久久精品无码一区二区| 久久人人爽人人爽人人片av高请| 久久久亚洲裙底偷窥综合| 无码人妻少妇久久中文字幕| 亚洲精品国产综合久久一线| 亚洲国产精品狼友中文久久久|