Qt QLabel不';t显示QPixmap

Qt QLabel不';t显示QPixmap,qt,video-streaming,qlabel,qpixmap,Qt,Video Streaming,Qlabel,Qpixmap,我试图用下面的代码在QLabel中显示视频帧,但不幸的是,视频没有显示在QLabel上。我将QabStrictVideoSurface继承到CameraFrameGrabber中 bool CameraFrameGrabber::present(const QVideoFrame &frame) { qDebug() << __FUNCTION__; if (frame.isValid()) { QVideoFrame cloneFrame(

我试图用下面的代码在QLabel中显示视频帧,但不幸的是,视频没有显示在QLabel上。我将QabStrictVideoSurface继承到CameraFrameGrabber中

bool CameraFrameGrabber::present(const QVideoFrame &frame)
{

    qDebug() << __FUNCTION__;
    if (frame.isValid()) {
        QVideoFrame cloneFrame(frame);
        cloneFrame.map(QAbstractVideoBuffer::ReadOnly);
        const QImage image(cloneFrame.bits(),
            cloneFrame.width(),
            cloneFrame.height(),
            QVideoFrame::imageFormatFromPixelFormat(cloneFrame.pixelFormat()));
        if (MainWindow* child = dynamic_cast<MainWindow*>(this)) {
            //QGraphicsScene *scene = new QGraphicsScene(this);
            //scene->addPixmap(QPixmap::fromImage(image));
            //scene->setSceneRect(image.rect());
            child->ui->label->setPixmap(QPixmap::fromImage(image));

            child->ui->label->update();
            //child->ui->graphicsView->setScene(scene);
            //child->ui->graphicsView->update();

        }
        //emit frameAvailable(image);
        cloneFrame.unmap();
        return true;
    }
    return false;

}
bool-CameraFrameGrabber::present(const-QVideoFrame&frame)
{
qDebug()addPixmap(QPixmap::fromImage(image));
//场景->设置场景竖立(image.rect());
child->ui->label->setPixmap(QPixmap::fromImage(image));
子->用户界面->标签->更新();
//子->用户界面->图形视图->设置场景(场景);
//子->用户界面->图形视图->更新();
}
//发射帧可用(图像);
cloneFrame.unmap();
返回true;
}
返回false;
}

问题在于视频帧格式与QLabel pixmap格式不匹配,还从主窗口删除了动态强制转换,并在Cameraframegrabber中添加了标签

QImage outImage = image.convertToFormat(QImage::Format_RGB888);
    myLabel->setPixmap(QPixmap::fromImage(outImage));

您是否尝试过调试并查看图像是否包含真实数据?我发现问题在于QVideoFrame的格式,它无法在QLabel中显示。有什么建议吗?