第一种:
qImg = new QImage(QSize(img->width,img->height), QImage::Format_RGB888); iplImg = cvCreateImageHeader(cvSize(img->width,img->height), 8,3); iplImg->imageData = (char*)qImg->bits(); if (img->origin == IPL_ORIGIN_TL) { cvCopy(img,iplImg,0); } else { cvFlip(img,iplImg,0); } cvCvtColor(iplImg,iplImg,CV_BGR2RGB);
iplImg=cvCloneImage(img); cvCvtColor(img,iplImg,CV_BGR2RGB); uchar* imgData = (uchar*)(iplImg->imageData);
qImg=new QImage(imgData,iplImg->width,iplImg->height,QImage::Format_RGB888);