Http://blog.sina.com.cn/s/blog_5c70dfc80100r257.html
The qimage class is generally used to process images in QT, but the qimage object cannot be directly displayed. To see the image, there are two methods at first.
1. Convert qimage to qpixmap and use qlabel: setpixmap ()
Image = new qimage ("D:/temp/xx.jpg ");
pixmap=newQPixmap();
pixmap->convertFromImage(*image);
label=newQLabel(this);
label->setGeometry(100,0,1000,700);
label->setPixmap(*pixmap);
2. directly draw in paintevent ()
void MyWindow::paintEvent(QPaintEvent*)
{
QPainter paint(this);
paint.drawImage(0,0,*image);
}
There are two methods to compare. Experiment shows that the first method is more efficient. Although the code is too open, the optimized qpixmap for display can reflect its advantages. Similarly, a 1200*1600 image is displayed. The first method requires almost no time and is displayed as 0 in milliseconds. The second method requires 15 ms, where a large amount of computation is required, the difference between 15 ms is quite large.