繁体   English   中英

使用SFML和Qt窗口未显示

[英]Using SFML and Qt window not showing

我试图让SFML在过去2天中与Qt创建者一起工作,但它却无法正常工作。 该程序无法创建新窗口,我不确定为什么。

应用输出

Starting E:\Programiranje\QT programi\build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\SMFLConsoleGame.exe...
The program has unexpectedly finished.
E:\Programiranje\QT programi\build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug\debug\SMFLConsoleGame.exe crashed

编译输出

14:57:51: Running steps for project SMFLConsoleGame...
14:57:51: Configuration unchanged, skipping qmake step.
14:57:51: Starting: "E:\Programiranje\QT\Tools\mingw482_32\bin\mingw32-make.exe" 
E:/Programiranje/QT/Tools/mingw482_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'E:/Programiranje/QT programi/build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_CORE_LIB -I..\SMFLConsoleGame -I"..\..\SFML\include\SFML" -I"..\..\QT\5.3\mingw482_32\include" -I"..\..\QT\5.3\mingw482_32\include\QtCore" -I"debug" -I"." -I"..\..\QT\5.3\mingw482_32\mkspecs\win32-g++" -o debug\main.o ..\SMFLConsoleGame\main.cpp
g++ -Wl,-subsystem,console -mthreads -o debug\SMFLConsoleGame.exe debug/main.o  -LE:/Programiranje/SFML/lib -lsfml-system -lsfml-window -lsfml-graphics -lsfml-audio -LE:/Programiranje/QT/5.3/mingw482_32/lib -lQt5Cored 
mingw32-make[1]: Leaving directory 'E:/Programiranje/QT programi/build-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-Debug'
14:57:52: The process "E:\Programiranje\QT\Tools\mingw482_32\bin\mingw32-make.exe" exited normally.
14:57:52: Elapsed time: 00:02.

的.pro

QT       += core

QT       -= gui

TARGET = SMFLConsoleGame

CONFIG   += console

CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp
LIBS+= -LE:/Programiranje/SFML/lib \
    -lsfml-system \
    -lsfml-window \
    -lsfml-graphics \
    -lsfml-audio
INCLUDEPATH += E:/Programiranje/SFML/include/SFML
CONFIG += c++11

main.cpp中

#include <iostream>
#include "System.hpp"
#include "Graphics.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

您好哈布斯堡,欢迎大家交流! 我目前没有测试该程序的设置,但我怀疑您使用的是错误的库。 我注意到您使用的是mingw,如果您查看sfml下载页面,则有2种类型的库(SJLJ和DW2),使用错误的库可能会导致崩溃,但是调试输出可以告诉您更多关于问题。

暂无
暂无

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

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