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. Qjpeg plugin not loaded; cannot call setPixmap() on a QLabel() with a JPG image
Qt 6.11 is out! See what's new in the release blog

Qjpeg plugin not loaded; cannot call setPixmap() on a QLabel() with a JPG image

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.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.
  • D Offline
    D Offline
    Deusdies
    wrote on last edited by
    #1

    I am trying to have a QLabel() display a pixmap JPG image from a file (which can't be in a resource file since it is downloaded from the web), but I am having problems loading it. The code is fairly simple:

    @label = QLabel()
    label.setPixmap(QPixmap("image.jpg"))@

    It works with PNG files, but it doesn't work with JPG files. I have Googled quite a bit and found that I needed to place the "imageformats" folder in the same folder where my script is located. However, even after doing this (and yes, qjpeg4.dll and others are there), it still doesn't work. I've also tried doing

    @path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats"
    app.addLibraryPath(path)@

    but that didn't help either.

    Again, it loads PNGs just fine, but it won't load JPGs. I've also noticed even before that it won't load ICO either, but I thought of it as an unrelated issue - however it doesn't seem that way now.

    It is worth noting that the application is not converted to an .exe at this point - it is ran through python.exe interpreter via PowerShell.

    If I do this:

    @QtGui.QImageReader.supportedImageFormats()@

    I get this:

    @[PySide.QtCore.QByteArray('bmp'), PySide.QtCore.QByteArray('pbm'), PySide.QtCore.QByteArray('pgm'), PySide.QtCore.QByteArray('png'), PySide.QtCore.QByteArray('ppm'), PySide.QtCore.QByteArray('xbm'), PySide.QtCore.QByteArray('xpm')]@

    Obviously JPG is not included - so the question basically is how to include jpg in this?

    My development environment is Windows 7 x64, PySide 1.1.0

    How can I solve this problem?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Remove imageformats from following path.

      @
      path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats"
      app.addLibraryPath(path)
      @

      The plugin path is PluginPath/imageformats/qjpeg4.dll

      Or you can simple move the imageformats/qjpeg4.dll to where your application located, for example

      @
      python27.exe [or your own xxxx.exe]
      imageformats/qjpeg4.dll
      @

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Deusdies
        wrote on last edited by
        #3

        Okay so if I understood you correctly...

        I tried changing path to

        @path = r"C:\Users\Deusdies\Documents\Work\myapp"@ (this folder has the imageformats folder in it, with all the plugins.)

        and to

        @path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats\qjpeg4.dll"@

        Neither of which solutions worked. The .py file that I am executing is in the "myapp" folder.

        Regards

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          [quote author="Deusdies" date="1337887611"]Okay so if I understood you correctly...

          I tried changing path to

          @path = r"C:\Users\Deusdies\Documents\Work\myapp"@ (this folder has the imageformats folder in it, with all the plugins.)

          and to

          @path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats\qjpeg4.dll"@
          [/quote]

          The formal is right, it will work if you qjpeg4.dll is copied form the right place. Make sure this if more or that one Qt libraries exist in your system.

          The later is always wrong.

          [quote author="Deusdies" date="1337887611"]
          Neither of which solutions worked. The .py file that I am executing is in the "myapp" folder.
          Regards[/quote]

          It does't matter where your .py/.pyw files located. what matters is where your executable program (XXXX.exe) located if you want to avoid addLibraryPath().

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Deusdies
            wrote on last edited by
            #5

            Thanks! I realized that the reason it didn't work with the former path was because I created an instance of the QDialog class before the app.addLibraryPath() method was called! Problem solved!

            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