Qt 6.11 is out! See what's new in the release
blog
Convert an image cv::Mat to QImage
3rd Party Software
2
Posts
2
Posters
5.2k
Views
1
Watching
-
Greetings.
I'm working on a project with Qt + OpenCV and I need to convert an image cv::Mat to QImage and / or viceversa. Does anyone know how to do?
Thanks in advance for any answers or comments.
-
Hello,
If you are using one of the types supported by QImage, you can use the constructor taking an (const) uchar * input.
And the same in reverse, get the data from QImage with the bits function.
As the doc state, look carefully for the lifetime of your data.
http://qt-project.org/doc/qt-4.8/qimage.html#QImage-4 and its friends