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. Image not showing in QLabel
Forum Updated to NodeBB v4.3 + New Features

Image not showing in QLabel

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.0k 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.
  • DriftwoodD Offline
    DriftwoodD Offline
    Driftwood
    wrote on last edited by Driftwood
    #1

    I don't get it. I have the image as it should be:

    Screenshot from 2021-08-24 20-38-54.png

    Yet when I run it, I get this:

    Screenshot from 2021-08-24 20-39-19.png

    I have it in a folder inside the project. But it doesn't show at showtime.

    This is Qt6 6 using CMake. Any insight on this will be appreciated.

    Thank you.

    eyllanescE 1 Reply Last reply
    1
    • DriftwoodD Driftwood

      I don't get it. I have the image as it should be:

      Screenshot from 2021-08-24 20-38-54.png

      Yet when I run it, I get this:

      Screenshot from 2021-08-24 20-39-19.png

      I have it in a folder inside the project. But it doesn't show at showtime.

      This is Qt6 6 using CMake. Any insight on this will be appreciated.

      Thank you.

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @Driftwood Are you using any qresource or are you using the absolute path of the image?

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      DriftwoodD 1 Reply Last reply
      0
      • eyllanescE eyllanesc

        @Driftwood Are you using any qresource or are you using the absolute path of the image?

        DriftwoodD Offline
        DriftwoodD Offline
        Driftwood
        wrote on last edited by Driftwood
        #3

        @eyllanesc - I have a .qrc folder for toolbar icons. Should I put the image in there? No, I'm not using an absolute path.

        eyllanescE 1 Reply Last reply
        0
        • DriftwoodD Driftwood

          @eyllanesc - I have a .qrc folder for toolbar icons. Should I put the image in there? No, I'm not using an absolute path.

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @Driftwood If you don't use absolute paths then they will be relative to the executable, so you have the following options:

          1. you use absolute paths OR
          2. You locate the resource (the image) relative to the executable that is in the build folder OR
          3. You use qresource.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          DriftwoodD 1 Reply Last reply
          3
          • eyllanescE eyllanesc

            @Driftwood If you don't use absolute paths then they will be relative to the executable, so you have the following options:

            1. you use absolute paths OR
            2. You locate the resource (the image) relative to the executable that is in the build folder OR
            3. You use qresource.
            DriftwoodD Offline
            DriftwoodD Offline
            Driftwood
            wrote on last edited by Driftwood
            #5

            @eyllanesc

            I've tried both 2 and 3 of your suggestions. The image in the first pic of my initial post is from an /image folder inside the Project folder. Looks fine in Creator. But when I run it, the image vanishes as seen in the 2nd pic.

            I'm setting the image path through Creator:

            Screenshot from 2021-08-25 10-11-43.png

            Everything looks great...until I run it.

            Why is Qt losing the image? What more needs to be done?

            Thank YouT 1 Reply Last reply
            0
            • DriftwoodD Driftwood

              @eyllanesc

              I've tried both 2 and 3 of your suggestions. The image in the first pic of my initial post is from an /image folder inside the Project folder. Looks fine in Creator. But when I run it, the image vanishes as seen in the 2nd pic.

              I'm setting the image path through Creator:

              Screenshot from 2021-08-25 10-11-43.png

              Everything looks great...until I run it.

              Why is Qt losing the image? What more needs to be done?

              Thank YouT Offline
              Thank YouT Offline
              Thank You
              wrote on last edited by Thank You
              #6

              @Driftwood

              Hello
              For your case, there must be something wrong with image directory
              If you are using .qrc then you can just right click on the name ( picture that you want to insert ) and select copy path or something like that then paste that in the url location (IN QT file revealer at left side(default) )

              Another way

              second.jpg

              Click on the down arrow

              and select
              Choose from resources
              Then select resource

              for absolute image

              just do the same click Choose from file
              and select the file

              Another way of achieving same thing since you are using UI for designing , you can simply use
              stylesheet

              #yourLabelName{
               border-image: url("url of the image here");
              }
              

              your_scrn.jpg

              Let's make QT free or It will go forever

              TRUE AND FALSE <3

              DriftwoodD 1 Reply Last reply
              3
              • Thank YouT Thank You

                @Driftwood

                Hello
                For your case, there must be something wrong with image directory
                If you are using .qrc then you can just right click on the name ( picture that you want to insert ) and select copy path or something like that then paste that in the url location (IN QT file revealer at left side(default) )

                Another way

                second.jpg

                Click on the down arrow

                and select
                Choose from resources
                Then select resource

                for absolute image

                just do the same click Choose from file
                and select the file

                Another way of achieving same thing since you are using UI for designing , you can simply use
                stylesheet

                #yourLabelName{
                 border-image: url("url of the image here");
                }
                

                your_scrn.jpg

                DriftwoodD Offline
                DriftwoodD Offline
                Driftwood
                wrote on last edited by
                #7

                @Thank-You

                I appreciate your explanation. I have it going now.

                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