Results 1 to 8 of 8

Thread: QImage

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default QImage

    hi,
    anyone know what can be the reason why sometimes this don't load the image and appear warning?
    Qt Code:
    1. QImage img("");
    2. cout << "text file name " << texFileName << endl;
    3. //this above print the name "file.jpg"; it print same thing when load works and when dosn't work!!
    4. if ( !img.load(texFileName))
    5. qWarning( "Could not read image file ONE ");
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage

    Do you use absolute paths?

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QImage

    no i don't; the path printed is "image/imm.png";
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage

    Quote Originally Posted by mickey
    no i don't;
    Then use them. If you run your program from a different directory, it won't be able to find that image.

    You can use QApplication::applicationDirPath() to construct an absolute path.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QImage

    I change its position and texNameFIle ="../dir/image.png"
    Qt Code:
    1. dir/myApp/images
    2. dir/other/image.png
    To copy to clipboard, switch view to plain text mode 
    now it's working; under images directory doesn't work...
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage

    Quote Originally Posted by mickey
    now it's working; under images directory doesn't work...
    Does it work with absolute paths?

    Do you use PNG or JPEG images?

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QImage

    Quote Originally Posted by jacek
    Does it work with absolute paths?
    I didin't try it; now it works with path above; maybe I changed the dir App in some place....?!
    Quote Originally Posted by jacek
    Do you use PNG or JPEG images?
    both them.....thanks
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage

    Quote Originally Posted by mickey
    maybe I changed the dir App in some place....?!
    Relative paths are relative to current directory, which might change depending on how you start your program.

    Quote Originally Posted by mickey
    both them....
    If JPEG images sometimes work and sometimes don't, then the problem lies in paths. If they aren't working at all, then you must make sure that you have a proper image format plugin.

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 10:10
  2. Diff between QImage, QPixmap, QPicture
    By nupul in forum Newbie
    Replies: 6
    Last Post: 30th April 2008, 02:02
  3. Qimage in RGB24
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 28th June 2006, 07:17
  4. QImage from 8 bit char* RGB buffer
    By tboloo in forum Qt Programming
    Replies: 13
    Last Post: 15th April 2006, 19:56
  5. Trouble with image painting (QPainter + QImage)
    By krivenok in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 20:25

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.