我在重写的qpushbutton中显示opencv调用来的视频图像,图像就奔溃了,然后我加了一个qlabel标签来显示相同的输出图像,程序没用奔溃,说明我生成的qimage是没有问题的,代码如下:
connect(timer,SIGNAL(timeout()),this,SLOT(released()));
void MainWindow::released()
{
Mat frame;
cap>>frame;
if(frame.empty()){
return;
}
cvtColor(frame,frame,CV_BGR2RGB);
QImage image(frame.data,frame.cols,frame.rows,QImage::Format_RGB888);
label->setPixmap(QPixmap::fromImage(image));
qDebug()<<image.byteCount();
QPalette p;
p.setBrush(QPalette::Button,QBrush(image));
bgp->button(0)->setPalette(p);
update();
}
希望能得到帮助,谢谢