Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I display a Mat image returned by a function in main.cpp in MainWindow using QLabel?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 893 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    georgiav
    wrote on 20 Feb 2021, 00:54 last edited by
    #1

    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.
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on 20 Feb 2021, 02:40 last edited by
      #2

      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

      1 Reply Last reply
      3

      1/2

      20 Feb 2021, 00:54

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved