Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Qt creator can't find Image.  (Read 1118 times)

0 Members and 1 Guest are viewing this topic.

DasOhmoff

  • Newbie
  • *
  • Posts: 17
    • View Profile
    • Email
Qt creator can't find Image.
« on: March 13, 2015, 09:29:13 pm »
Hi,

I wrote this code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow sf_window(sf::VideoMode(1280, 720, 32), "Test");
    sf::Event        sf_event;

    sf::Texture sf_texture;
    sf_texture.loadFromFile("Background.png");

    sf::Sprite sf_sprite(sf_texture);

    while(sf_window.isOpen())
    {
        while(sf_window.pollEvent(sf_event))
            if(sf_event.type == sf::Event::Closed)
                sf_window.close();

        sf_window.clear();
        sf_window.draw(sf_sprite);
        sf_window.display();
    }

    return 0;
}
 

I can compile and start the program, it tells me that sfml can’t open the file.
I tested it with g++ on my Linux and it worked perfectly, and because of that I think that I do something wrong with the path of the picture.

The image is in the location of the .pro file (Project file) and i think that qt creator should be able to find it.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Qt creator can't find Image.
« Reply #1 on: March 13, 2015, 09:42:06 pm »
The Qt Creator has nothing to do with "finding it". Your application will look for the image in its working directory. Find out what working directory the Qt Creator sets for application it runs.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything