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. No show of QPixmap

No show of QPixmap

Scheduled Pinned Locked Moved Solved General and Desktop
24 Posts 6 Posters 5.1k 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.
  • Stan HuangS Stan Huang

    @JKSH It still doesn't work.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by jsulm
    #10

    @Stan-Huang Come on, be a bit more proactive!
    Did you check whether your pixmap is null as @Christian-Ehrlicher suggested?
    Also, /exe/bv/image/sdkpic.jpg is an absolute path and looks strange - are you REALLY sure it is correct?
    Try what @SGaist suggested.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      What does file /exe/bv/image/sdkpic.jpg return ?

      Stan HuangS Offline
      Stan HuangS Offline
      Stan Huang
      wrote on last edited by Stan Huang
      #11

      @SGaist The return of "file /exe/bv/image/sdkpic.jpg" is:

      root@mitacimx6:/opt/BVDemo/smartbox# file /exe/bv/image/sdkpic.jpg
      /exe/bv/image/sdkpic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1108x1478, frames 3

      JKSHJ 1 Reply Last reply
      0
      • Stan HuangS Stan Huang

        @SGaist The return of "file /exe/bv/image/sdkpic.jpg" is:

        root@mitacimx6:/opt/BVDemo/smartbox# file /exe/bv/image/sdkpic.jpg
        /exe/bv/image/sdkpic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1108x1478, frames 3

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #12

        @Stan-Huang said in No show of QPixmap:

        The return of "file /exe/bv/image/sdkpic.jpg" is:

        root@mitacimx6:/opt/BVDemo/smartbox# file /exe/bv/image/sdkpic.jpg
        /exe/bv/image/sdkpic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1108x1478, frames 3

        OK, it looks like the file is valid.

        Next, check if Qt can understand the file format. What do you get when you call
        qDebug() << QImageReader::supportedImageFormats() ? (remember #include <QDebug> and #include <QImageReader>)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        Stan HuangS 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @Stan-Huang said in No show of QPixmap:

          I'm sure it's existent and readable.

          Although you are 'sure' you should check it with the function I pointed you to ...

          Stan HuangS Offline
          Stan HuangS Offline
          Stan Huang
          wrote on last edited by
          #13

          @Christian-Ehrlicher setPixmap(pixmap_RoadFault) is void, so no return.

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

            @Stan-Huang said in No show of QPixmap:

            setPixmap(pixmap_RoadFault) is void, so no return.

            Pleae read my link: http://doc.qt.io/qt-5/qpixmap.html#isNull - no setPixmap() but QPixmap::isNull() ...

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

            Stan HuangS 1 Reply Last reply
            0
            • JKSHJ JKSH

              @Stan-Huang said in No show of QPixmap:

              The return of "file /exe/bv/image/sdkpic.jpg" is:

              root@mitacimx6:/opt/BVDemo/smartbox# file /exe/bv/image/sdkpic.jpg
              /exe/bv/image/sdkpic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1108x1478, frames 3

              OK, it looks like the file is valid.

              Next, check if Qt can understand the file format. What do you get when you call
              qDebug() << QImageReader::supportedImageFormats() ? (remember #include <QDebug> and #include <QImageReader>)

              Stan HuangS Offline
              Stan HuangS Offline
              Stan Huang
              wrote on last edited by
              #15

              @JKSH The return is:
              ("bmp", "cur", "gif", "ico", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "xbm", "xpm")

              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @Stan-Huang said in No show of QPixmap:

                setPixmap(pixmap_RoadFault) is void, so no return.

                Pleae read my link: http://doc.qt.io/qt-5/qpixmap.html#isNull - no setPixmap() but QPixmap::isNull() ...

                Stan HuangS Offline
                Stan HuangS Offline
                Stan Huang
                wrote on last edited by
                #16

                @Christian-Ehrlicher said in No show of QPixmap:

                setPixmap

                QPixmap::isNull() returned 'false'

                J.HilkJ 1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #17

                  What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?

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

                  Stan HuangS 2 Replies Last reply
                  0
                  • Stan HuangS Stan Huang

                    @Christian-Ehrlicher said in No show of QPixmap:

                    setPixmap

                    QPixmap::isNull() returned 'false'

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by J.Hilk
                    #18

                    @Stan-Huang
                    It's not quite clear from the code you posted, but are you sure that palette_RoadFault is not set to something invalid somewhere else in your code, and that palette_RoadFault persists outside the scope of your function?

                    QBrush expects a const reference to a QPixmap, I don't think it will take ownership or make a copy of the QPixmap for drawing.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?

                      Stan HuangS Offline
                      Stan HuangS Offline
                      Stan Huang
                      wrote on last edited by
                      #19

                      @SGaist I did it but still doesn't work:
                      ui->label->setGeometry(20,20,60,20);
                      ui->label->setPixmap(pixmap_RoadFault);
                      ui->label->show();

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?

                        Stan HuangS Offline
                        Stan HuangS Offline
                        Stan Huang
                        wrote on last edited by
                        #20

                        @SGaist I did but still doesn't work:

                        				ui->label->setGeometry(20,20,60,20);
                        				ui->label->setPixmap(pixmap_RoadFault);
                        				ui->label->show();
                        
                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #21

                          Don't set the geometry since you have a designer based UI, that will let QLabel in its original place to show the pixmap.

                          If it's still not working, then test again with another image. And if possible, share that file with us so that we can test it on our ends.

                          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
                          1
                          • Stan HuangS Offline
                            Stan HuangS Offline
                            Stan Huang
                            wrote on last edited by
                            #22

                            That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.

                            JKSHJ 1 Reply Last reply
                            0
                            • Stan HuangS Stan Huang

                              That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.

                              JKSHJ Offline
                              JKSHJ Offline
                              JKSH
                              Moderators
                              wrote on last edited by
                              #23

                              @Stan-Huang said in No show of QPixmap:

                              That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.

                              I'm glad to hear that you've got it working now.

                              Like I said 10 days ago, it's best to use simple examples. I even wrote a full program for you that works, but you didn't use it.

                              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                              Stan HuangS 1 Reply Last reply
                              2
                              • JKSHJ JKSH

                                @Stan-Huang said in No show of QPixmap:

                                That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.

                                I'm glad to hear that you've got it working now.

                                Like I said 10 days ago, it's best to use simple examples. I even wrote a full program for you that works, but you didn't use it.

                                Stan HuangS Offline
                                Stan HuangS Offline
                                Stan Huang
                                wrote on last edited by
                                #24

                                @JKSH Yes. I didn't do it 10 days ago due to 9-day lunar new year vacation. Thanks very much.

                                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