Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How can I display a Mat image returned by a function in main.cpp in MainWindow using QLabel?



  • Hi, how can I take the Mat image (OpenCV object) which is returned by a function imageCollage() in main.cpp and display it in the main window using QLabel?
    So far I managed to display a simple image by giving the image path:

                       QPixmap pm("/home/csimage/project/church.JPEG");
                             ui->label->setPixmap(pm);
                             ui->label->setScaledContents(true);
                     
         Any pointers to helpful resources/tutorials would be much appreciated.


  • You need to convert the Mat to a QImage, and then create a QPixmap from the QImage.
    Have a look at this project: https://github.com/dbzhang800/QtOpenCV


Log in to reply