简体   繁体   English

Qt Creator不显示SFML窗口

[英]Qt Creator not displaying SFML windows

I've recently set up qt creator to work with SFML, and I tried running a piece of code as a test to see if it works. 我最近设置了qt creator与SFML一起使用,并且我尝试运行一段代码作为测试以查看其是否有效。 I must note the code bellow works perfectly in Codeblocks IDE but in qt creator it simply displays a console with the text "Press RETURN to close this window..." 我必须注意,下面的代码在Codeblocks IDE中可以很好地工作 ,但是在qt Creator中,它仅显示带有文本“按RETURN关闭此窗口...”的控制台。

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream> 

using namespace std;
using namespace sf;

Window w(VideoMode(350,350,32), "Tic Tac Toe"); Event e1; const Input&
in1 = w.GetInput();

int main() {
    while(w.IsOpened())
    {
        w.Display();
    }
    return EXIT_SUCCESS;
}

Here is my .pro file: 这是我的.pro文件:

INCLUDEPATH += C:\SFML-1.6\include
LIBS += C:\SFML-1.6\lib\sfml-system.lib \
    C:\SFML-1.6\lib\sfml-window.lib \
    C:\SFML-1.6\lib\sfml-graphics.lib \
    C:\SFML-1.6\lib\sfml-audio.lib \
    C:\SFML-1.6\lib\sfml-network.lib

Never in a million years did I imagine working with SFML on my favorite IDE is so difficult, what is the problem? 一百万年来,我从未想象过在我最喜欢的IDE上使用SFML如此困难,这是什么问题?

You should not use global object. 您不应该使用全局对象。 They might mess up with SFML's internal. 他们可能会弄乱SFML的内部。

Also you should process events. 您还应该处理事件。 Not doing so might be the reason of your issue. 不这样做可能是你的问题的原因。

Try the example from the tutorial . 尝试教程中 的示例

If you're discovering SFML for the first time I strongly suggest you start with 2.0 instead of the old, buggy and deprecated 1.6 version. 如果您是第一次发现SFML,我强烈建议您从2.0开始,而不是旧的,越野车和已弃用的1.6版本。 Have a look at some discussions on the official forum to understand why 2.0 is better although it is currently "only" a release candidate. 查看官方论坛上的一些讨论,以了解为什么2.0更好,尽管它目前“仅”是一个候选发布版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM