直到流萤成飞火 2016-08-15 01:58 采纳率: 0%
浏览 1421

使用QPalette给重写的qpushbutton绘制背景图 程序奔溃

我在重写的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();

}
希望能得到帮助,谢谢

  • 写回答

3条回答 默认 最新

  • dabocaiqq 2016-08-15 02:18
    关注
    评论

报告相同问题?