QString fileName=QFileDialog::getOpenFileName(this,tr("fileDialog"),"C:",tr("img(*png *jpg)"));
string srcname;
QTextCodec *code=QTextCodec::codecForName("gb18030"); //支持中文
srcname=code->fromUnicode(fileName).data();
srcmat=imread(srcname,1); //读取图片文件
Mat srcmat2;
cvtColor(srcmat,srcmat2,CV_BGR2RGB);
QImage img =QImage((const unsigned char*)srcmat2.data, // uchar* data
srcmat2.cols, srcmat2.rows, // width height
srcmat2.step,
QImage::Format_RGB888); //format
QImage dstimg=img.scaled(ui->label->size());
以上来自https://blog.csdn.net/jialeheyeshu/article/details/51445893