• <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編程
             
            久久精品人人做人人爽电影| 亚洲国产天堂久久综合网站| 久久久精品视频免费观看| 国产精品日韩欧美久久综合| 国产精品伊人久久伊人电影| 欧洲性大片xxxxx久久久| 综合久久给合久久狠狠狠97色| 97视频久久久| 亚洲精品高清国产一久久| 人妻无码精品久久亚瑟影视| 久久久久久免费视频| 青青青国产成人久久111网站| 久久青青国产| 99久久久国产精品免费无卡顿| 久久免费99精品国产自在现线 | 91久久婷婷国产综合精品青草 | 99久久综合狠狠综合久久| 久久久久亚洲AV无码专区首JN| 亚洲午夜精品久久久久久人妖| 波多野结衣久久一区二区| 久久国产成人| 亚洲综合伊人久久综合| 久久亚洲欧美国产精品| 伊人久久大香线蕉综合5g| 国产A级毛片久久久精品毛片| 日韩av无码久久精品免费| 日韩电影久久久被窝网| 精品综合久久久久久97超人 | 国产成人综合久久精品红| 岛国搬运www久久| 国产成人无码精品久久久免费| 久久Av无码精品人妻系列| 久久99久国产麻精品66| 伊色综合久久之综合久久| 蜜臀久久99精品久久久久久| 精品综合久久久久久88小说| 色综合久久88色综合天天| 亚洲国产成人久久综合一| 91久久成人免费| 久久免费99精品国产自在现线| 久久亚洲国产成人影院网站|