Results 1 to 1 of 1

Thread: QPixmap load() returns 0 for valid(?) png [Solved]

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPixmap load() returns 0 for valid(?) png [Solved]

    Edit:
    The apparent answer: Yes there was a path error involved, as simple as that.

    --


    Hej,

    In short I am attempting to load a png image from file:

    Qt Code:
    1. QPixmap pixmapSrc;
    2.  
    3. bool loaded = pixmapSrc.load("pixmaps/ps1.png");
    4. std::cout << "image loaded = " << loaded << std::endl;
    5. pixmap.setPixmap(pixmapSrc);
    To copy to clipboard, switch view to plain text mode 
    result: image loaded = 1
    It works fine, the image loads and is presented properly on my Scene etc.

    In other functions of the same class I am able to change the pixmapSrc by repeating the above step with another source file (e.g "pixmaps/ps2.png") and the scene is updated with the new image.

    Now, to my issue:
    I am not able to load any new images in the same fashion.

    Qt Code:
    1. bool loaded = pixmapSrc.load("pixmaps/xyz.png"); //new image
    2. std::cout << "image loaded = " << loaded << std::endl;
    3. pixmap.setPixmap(pixmapSrc);
    To copy to clipboard, switch view to plain text mode 
    result: image loaded = 0

    At first I thought there was something wrong with the images themselves so I renamed an image I had previously confirmed OK and gave it a new name, and it won't load.

    I'm obviously missing something along the way (I've changed my IDE to QT Creator recently, but if there was a config problem, why does the other images work?)

    Thanks
    Last edited by mengedej; 12th March 2010 at 23:25. Reason: Solved

Similar Threads

  1. No valid Qt version set?
    By RoryWalsh in forum Qt Tools
    Replies: 4
    Last Post: 21st October 2009, 09:02
  2. error for No valid Qt version set
    By zhongxichuan in forum Qt Tools
    Replies: 2
    Last Post: 16th October 2009, 07:45
  3. QPixmap/QImage fail to load jpg files in vista
    By schan117 in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 16:48
  4. valid a path name
    By klaus1111 in forum Newbie
    Replies: 3
    Last Post: 23rd July 2006, 16:07
  5. QPixmap xx.scaledToWidth dont Scale but load...
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2006, 00:21

Tags for this Thread

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.