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. Pixmap::fromImage the mistery.
Qt 6.11 is out! See what's new in the release blog

Pixmap::fromImage the mistery.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 502 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Seba the student
    wrote on last edited by
    #1

    Hello.
    I'm working on receiving data from gstreamer in QT widgets and I found one surprise:
    I create an QImage from gstreamer data and create a QPixmap from that image to display the data like this:
    QPixmap pixmap;
    pixmap.fromImage (image);

    and display the data:
    ui->imageLabel->setPixmap(pixmap);

    and it does not display any data...

    but if I use:
    ui->imageLabel->setPixmap(QPixmap::fromImage(image)); instead of ui->imageLabel->setPixmap(pixmap);

    It does display the data I'm expected to see.

    Does anyone have an idea why is this behaving like that ?

    I thought that pixmap.fromImage(image) returns exacly the same results as QPixmap::fromImage(image).

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      QPixmap::fromImage() is a static function which returns the QPixmap.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • S Offline
        S Offline
        Seba the student
        wrote on last edited by
        #3

        Yeea, that's what I missed reading the docs. Thanks a lot !

        1 Reply Last reply
        1
        • BondrusiekB Offline
          BondrusiekB Offline
          Bondrusiek
          wrote on last edited by
          #4

          @Seba-the-student said in Pixmap::fromImage the mistery.:

          QPixmap pixmap;
          pixmap.fromImage (image);

          Replace to:

          QPixmap pixmap;
          pixmap = QPixmap::fromImage (image);
          You must hold data from image somewhere.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi and welcome to devnet,

            If working with video, recent versions of Qt allows to use custom GStreamer pipelines so why not take advantage of that rather that doing things manually ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

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