Help with SFML Problem?

I got SFML to finally work with Qt Creator (I tried using it with Code::Blocks, didn't work) and I ran into a problem, again. Using the "Window" library, I cannot get the window to open. I'll post my code, then describe the problem below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <SFML/Window.hpp>

int main()
{
    sf::Window window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }
    }

    return 0;
}

Note, this is the same exact code from webpage:
http://www.sfml-dev.org/tutorials/2.1/window-window.php


Now onto my problem.
Using this code, I cannot open the window, as I previously said. No errors come up, either. The console, however, does open. Nothing else happens. It is really strange. Now, one thing I did do, is on the site, I got the TJM version, because that is supposed to work with CB better, and after giving up on that, I just used the same version with Qt Creator. Would that make a difference? I know that I am linking to the files correctly, because Qt Creator has the drop down menu after the dot separators a menu comes up of all the members of the objects class.

Anyway, just thought I'd try to be as informative as possible. Thanks for any help!


PS: I did post a thread on the SFML forum, but you guys are usually a lot more helpful than what I got from them
> I know that I am linking to the files correctly,
> because Qt Creator has the drop down menu after the dot separators
> a menu comes up of all the members of the objects class.
i don't see how an autocomplete feature has any relationship with the build process.


> I cannot open the window
¿what windows manager are you using?
Also, try to put window.display(); after line 17
Well, to be honest, I didn't think about build process. I just thought Qt Creator would recognize the SFML code because it had all the stuff I mentioned.

And I put
window.display();
after line 17. Still, no dice.
I don't know what the TJM version is so I can't help you there, but your code works fine with Qt Creator 3.0.1 & SFML 2.1 on my machine.

I created a new C++ project and added the "LIBS +=" line to the project file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
LIBS += -lsfml-system -lsfml-window

SOURCES += main.cpp


Oh, probably should have put the .pro code here too, my bad. Here's that:


TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

1
2
3
4
5
6
7
8
9
SOURCES += main.cpp

LIBS += -LC:/SFML/lib

CONFIG(release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-main -lsfml-network -lsfml-window -lsfml-system
CONFIG(debug, debug|release): LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-main-d -lsfml-network-d -lsfml-window-d -lsfml-system-d
CONFIG += c++11
INCLUDEPATH += C:/SFML/include
DEPENDPATH += C:/SFML/include


But I will try the MinGW version for the meantime, keep you guys posted, and if you find anything, don't hesitate to mention it!
Last edited on
Just tried the MinGW version. Still nothing.
I have Qt Creator 3.0.1, too.
Except there is something new. Now, the debugger console says "Cannot obtain handle to the inferior: The parameter is incorrect" without any line numbers to check. The code still runs, too.
Have you tried compiling a release version?
I just did. And I also noticed something. When I go to exit the program through the Application Output, it says "SFMLapp (name of my application) is still running. Force quit?" Maybe something is wrong with the code?
Topic archived. No new replies allowed.