Results 1 to 3 of 3

Thread: image.load

  1. #1
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default image.load

    Hi,

    I have copied the breakout game from the website http://www.zetcode.com/gui/qt4/breakoutgame.
    But I don't see the images, what am I doing wrong?

    Regards,
    Arend

    Qt Code:
    1. #include "brick.h"
    2. #include <iostream>
    3. #include <QDebug>
    4.  
    5. Brick::Brick(int x, int y)
    6. {
    7. image.load("brick.png");
    8. destroyed = FALSE;
    9. rect = image.rect();
    10. qDebug()<<rect;
    11. rect.translate(x, y);
    12. }
    To copy to clipboard, switch view to plain text mode 

    etc.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: image.load

    It's likely because you are using relative file path to the image. If the current working directory when the application is launched is different than the directory where the image is located, the path will not be correct and the image will fail to load.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2012
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: image.load

    Thnx, that's what I need.

  4. The following user says thank you to Arend for this useful post:


Similar Threads

  1. how to load image from one ui to another
    By trupti in forum Newbie
    Replies: 4
    Last Post: 3rd January 2011, 12:03
  2. how to load image from one ui to another
    By trupti in forum Qt Programming
    Replies: 0
    Last Post: 3rd January 2011, 05:43
  3. how do load image
    By yuvaraj.yadav in forum Qt Programming
    Replies: 5
    Last Post: 21st April 2009, 05:31
  4. Is there a better way to load a big image?
    By learning_qt in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2008, 15:00
  5. best way to load image from db
    By C167 in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2008, 18:24

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.