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

display image in qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.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.
  • R Offline
    R Offline
    Rameshguru
    wrote on 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
    0
    • sankarapandiyanS Offline
      sankarapandiyanS Offline
      sankarapandiyan
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • sankarapandiyanS Offline
          sankarapandiyanS Offline
          sankarapandiyan
          wrote on 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

            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 last edited by
            #5

            @Rameshguru
            Is your image a QPixmap?

            1 Reply Last reply
            0
            • R Rameshguru

              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 last edited by
              #6

              @Rameshguru
              Show the code where you create the image.

              R 1 Reply Last reply
              0
              • sankarapandiyanS Offline
                sankarapandiyanS Offline
                sankarapandiyan
                wrote on 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

                  @Rameshguru
                  Show the code where you create the image.

                  R Offline
                  R Offline
                  Rameshguru
                  wrote on 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
                  1
                  • R Rameshguru

                    @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 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

                    • Login

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