Results 1 to 3 of 3

Thread: JPG not working when calling setPixmap() on QLabel

  1. #1
    Join Date
    Mar 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default JPG not working when calling setPixmap() on QLabel

    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:

    Qt Code:
    1. label = QLabel()
    2. label.setPixmap(QPixmap("image.jpg"))
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats"
    2. app.addLibraryPath(path)
    To copy to clipboard, switch view to plain text mode 
    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.

    My development environment is Windows 7 x64, PySide 1.1.0

    How can I solve this problem?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: JPG not working when calling setPixmap() on QLabel

    Sounds like the binaries in the imageformats folder do not match the binaries of the Qt libraries you are using, i.e. debug vs. release, built with the same compiler version etc. Where did you get the imageformats folder from?

  3. #3
    Join Date
    Mar 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: JPG not working when calling setPixmap() on QLabel

    From the PySide folder in the Python27 folder on my machine.

    But anyway, I solved the problem. I removed the "imageformats" part from the path above, then added the path to the library. It works now.

Similar Threads

  1. QLabel and setPixmap causes flickering
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 30th August 2010, 10:40
  2. QLabel setPixmap doesnt work
    By arpspatel in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2010, 22:24
  3. QLabel setPixmap only works twice?
    By December in forum Qt Programming
    Replies: 0
    Last Post: 28th February 2010, 10:59
  4. qlabel can't use setPixmap() function
    By emailhy in forum Qt Programming
    Replies: 1
    Last Post: 24th December 2009, 23:30
  5. QLabel not resize in setPixmap()
    By xgoan in forum Newbie
    Replies: 3
    Last Post: 23rd October 2006, 12:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.