Display QImage with QtGui

Simple, but complete example showing how to display QImage might look like this: #include <QtGui/QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QImage myImage; myImage.load(“test.png”); QLabel myLabel; myLabel.setPixmap(QPixmap::fromImage(myImage)); myLabel.show(); return a.exec(); }

Enabling JPEG support for QImage in py2exe-compiled Python scripts?

After hours of stumbling around with the same issue, I’d like to share the solution that worked for me on windows vista: using python2.6 copy the following directory into your dist directory generated by py2exe: C:\Python26\Lib\site-packages\PyQt4\plugins\imageformats I just dropped the imageformats directory directly into my dist directory, without any further modifications to qt.conf or anything … Read more

cv::Mat to QImage and back

Code looks fine with one exception. Memory management. cv::Mat doesn’t work like QImage in this mater. Remember that QImage is using copy on write mechanism and shares memory for each copy. cv::Mat also shares memory but it doesn’t do copy on write (I’m also new with open cv (2 weeks) so I can’t explain yet … Read more

How to convert an OpenCV cv::Mat to QImage

Michal Kottman’s answer is valid and give expected result for some images but it’ll fail on some cases. Here is a solution i found to that problem. QImage imgIn= QImage((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); Difference is adding img.step part. qt won’t complain without it but some images won’t show properly without it. Hope this … Read more