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. display image in qt
Forum Updated to NodeBB v4.3 + New Features

display image in qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.2k 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.
  • R Offline
    R Offline
    Rameshguru
    wrote on 14 Jul 2018, 04:48 last edited by
    #1

    how to display image in qt
    i have use ui->label->setpixmap(image)

    but this code not working if other method is there please mention

    K 2 Replies Last reply 14 Jul 2018, 05:00
    0
    • S Offline
      S Offline
      sankarapandiyan
      wrote on 14 Jul 2018, 04:56 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • S Offline
        S Offline
        sankarapandiyan
        wrote on 14 Jul 2018, 04:58 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • S Offline
          S Offline
          sankarapandiyan
          wrote on 14 Jul 2018, 04:59 last edited by
          #4

          Try this method bro,
          The "Choose file" do NOT work with random paths.
          it will become relative
          "
          label->setPixmap(QPixmap(QString::fromUtf8("../Pictures/taskbar3.png")));
          "
          But when run , the app is in the build folder and the pictures is NOT to be found with the relative path that is
          from .pro location.

          So use resource file or load them your self with the correct path.

          Just look in the setupUI function. you can see the paths it will use.
          Then check from your build folder. its no longer correct.

          1 Reply Last reply
          0
          • R Rameshguru
            14 Jul 2018, 04:48

            how to display image in qt
            i have use ui->label->setpixmap(image)

            but this code not working if other method is there please mention

            K Offline
            K Offline
            kenchan
            wrote on 14 Jul 2018, 05:00 last edited by
            #5

            @Rameshguru
            Is your image a QPixmap?

            1 Reply Last reply
            0
            • R Rameshguru
              14 Jul 2018, 04:48

              how to display image in qt
              i have use ui->label->setpixmap(image)

              but this code not working if other method is there please mention

              K Offline
              K Offline
              kenchan
              wrote on 14 Jul 2018, 05:03 last edited by
              #6

              @Rameshguru
              Show the code where you create the image.

              R 1 Reply Last reply 14 Jul 2018, 05:11
              0
              • S Offline
                S Offline
                sankarapandiyan
                wrote on 14 Jul 2018, 05:07 last edited by
                #7

                http://www.qtcentre.org/threads/45104-Image-not-appearing-in-Qlabel-after-compiling

                see thiz and clear your doubts

                1 Reply Last reply
                0
                • K kenchan
                  14 Jul 2018, 05:03

                  @Rameshguru
                  Show the code where you create the image.

                  R Offline
                  R Offline
                  Rameshguru
                  wrote on 14 Jul 2018, 05:11 last edited by
                  #8

                  @kenchan

                  char* imgL = reinterpret_cast<char*>(pImageBuffer);
                  QImage imgLNew(reinterpret_cast<uchar*>(imgL), 400, 300, QImage::Format_RGB888);
                  imgLNew.save("new.tif");
                  QPixmap image1 = QPixmap::fromImage(imgLNew);

                  this is my code sir

                  K 1 Reply Last reply 14 Jul 2018, 07:16
                  1
                  • R Rameshguru
                    14 Jul 2018, 05:11

                    @kenchan

                    char* imgL = reinterpret_cast<char*>(pImageBuffer);
                    QImage imgLNew(reinterpret_cast<uchar*>(imgL), 400, 300, QImage::Format_RGB888);
                    imgLNew.save("new.tif");
                    QPixmap image1 = QPixmap::fromImage(imgLNew);

                    this is my code sir

                    K Offline
                    K Offline
                    kenchan
                    wrote on 14 Jul 2018, 07:16 last edited by kenchan
                    #9

                    @Rameshguru
                    Does the tif file you are saving look correct? How exactly does it not work?
                    Are you aware of this requirement for the constructor you are using "data must be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned"?, make sure your data conforms to that.

                    1 Reply Last reply
                    1

                    7/9

                    14 Jul 2018, 05:07

                    • Login

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