Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Image not loading using Designer and Pixmap
Forum Updated to NodeBB v4.3 + New Features

Image not loading using Designer and Pixmap

Scheduled Pinned Locked Moved Unsolved Qt for Python
8 Posts 3 Posters 1.4k 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.
  • A Offline
    A Offline
    artiekastle
    wrote on last edited by
    #1

    Hey, I am using pyqt5 and tried to add a logo to the gui that i am currently making, with the help of rich text as well as pixmap in the python for qt designer, and it shows well on the designer itself but when I run the python script the image is not loading, and i dont understand why exactly, can someone help?

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

      Hi,

      How is that image passed ?
      A path to a file in your system ?
      Through Qt's resource system ?

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

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        How is that image passed ?
        A path to a file in your system ?
        Through Qt's resource system ?

        A Offline
        A Offline
        artiekastle
        wrote on last edited by
        #3

        @SGaist this is what I did:
        I used the label display widget and then changed the rich text of the label in which I add a resource file leading to the logo that i want to add and then added that resource file on the rich text.
        Additionally, I changed the pixmap of the label and selected the same resource file image that I had created for the rich text alteration.
        Did I do something wrong? I can see it load on the designer however it is not showing up when I run the application through my python script.

        JonBJ 1 Reply Last reply
        0
        • A artiekastle

          @SGaist this is what I did:
          I used the label display widget and then changed the rich text of the label in which I add a resource file leading to the logo that i want to add and then added that resource file on the rich text.
          Additionally, I changed the pixmap of the label and selected the same resource file image that I had created for the rich text alteration.
          Did I do something wrong? I can see it load on the designer however it is not showing up when I run the application through my python script.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @artiekastle
          In a word: I imagine somewhere in what you did you specified a path to the physical image file? If that is a relative path then it is relative to "the current directory". And that may not be the same when in the Designer/Creator versus what it is when you run your Python script (you don't say where/how you do that).

          Try to see if you can find such a path (.ui file or generated .py file). Either make it absolute, so it works independently of the current dircetory, or consider moving over to Qt resource files for it, which "embed" the actual image in the executable (not sure how this works for Python, but there will be documentation/links for this out there). t any rate look to see if that seems to be the issue.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            artiekastle
            wrote on last edited by
            #5

            @JonB So I added the image as a static path to like the current directory where both the main.py file which has the code and the other .ui.py files also are located. Since all the files including the logo png file are located in one location. I added a resource file in the designer redirecting to where the logo file is located. But the logo is still not loading.

            SGaistS 1 Reply Last reply
            0
            • A artiekastle

              @JonB So I added the image as a static path to like the current directory where both the main.py file which has the code and the other .ui.py files also are located. Since all the files including the logo png file are located in one location. I added a resource file in the designer redirecting to where the logo file is located. But the logo is still not loading.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @artiekastle if you are using a resource file you have to use rcc to build a python file out of it in order to use it in your application.

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

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                @artiekastle if you are using a resource file you have to use rcc to build a python file out of it in order to use it in your application.

                A Offline
                A Offline
                artiekastle
                wrote on last edited by
                #7

                @SGaist im sorry im a little new to this, do you know how I could do that?

                SGaistS 1 Reply Last reply
                0
                • A artiekastle

                  @SGaist im sorry im a little new to this, do you know how I could do that?

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @artiekastle sure: follow the documentation :-)

                  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