您好任何人都可以帮我弄清楚如何解决这个错误消息?我试图将Qt3工作代码重写为Qt4,用于将IplImage转换为QImage并找到“正确的转换类型”,但是我的代码如下所示导致“ ISO C ++禁止声明'QImage',没有类型 “
....
QImage *qqImage;
if (this->data->nChannels == 1)
{
QVector<QRgb> myColorTable;
for (int i = 0; i < 256; i++)
myColorTable.push_back(qRgb(i, i, i)); //colorTable[i]);
qqImage = new QImage(qImageBuffer, width, height, QImage::Format_Indexed8);
}
else
{
qqImage = new QImage(qImageBuffer, width, height, QImage::Format_RGB32);
}
return qqImage;
答案 0 :(得分:1)
下面的代码片段适用于我的Qt4应用程序,请尝试一下。
// img1 and img2 are Mat objects, img1 is grayscale,
// img2 is three channel RGB image
QImage qimg1,qimg2;
if (this->data->nChannels == 1){
qimg1=QImage(img1.data,img1.cols,img1.rows,QImage::Format_Indexed8);
}
else {
qimg2=QImage(img2.data,img2.cols,img2.rows,QImage::Format_RGB888);
}