使用SFML和Qt窗口不显示

Using SFML and Qt window not showing

本文关键字:显示 窗口 Qt SFML 使用      更新时间:2023-10-16

我试图让SFML工作与Qt的创造者在过去的2天,但它只是不工作。程序在创建新窗口时失败,我不确定原因。

<<p> 应用程序输出/strong>
Starting E:ProgramiranjeQT programibuild-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-DebugdebugSMFLConsoleGame.exe...
The program has unexpectedly finished.
E:ProgramiranjeQT programibuild-SMFLConsoleGame-Desktop_Qt_5_3_MinGW_32bit-DebugdebugSMFLConsoleGame.exe crashed

编译输出

14:57:51: Running steps for project SMFLConsoleGame...
14:57:51: Configuration unchanged, skipping qmake step.
14:57:51: Starting: "E:ProgramiranjeQTToolsmingw482_32binmingw32-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"....SFMLincludeSFML" -I"....QT5.3mingw482_32include" -I"....QT5.3mingw482_32includeQtCore" -I"debug" -I"." -I"....QT5.3mingw482_32mkspecswin32-g++" -o debugmain.o ..SMFLConsoleGamemain.cpp
g++ -Wl,-subsystem,console -mthreads -o debugSMFLConsoleGame.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:ProgramiranjeQTToolsmingw482_32binmingw32-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;
}

哈布斯堡你好,欢迎来stack exchange!我目前没有一个设置来测试这一点,但我怀疑你正在使用错误的库。我注意到您正在使用mingw,如果您查看sfml下载页面,有2种类型的库(SJLJ和DW2),使用错误的库可能导致崩溃,但是,调试输出可以告诉更多关于这个问题。