V
V
Vladimir Korshunov2021-07-19 11:56:35
Qt
Vladimir Korshunov, 2021-07-19 11:56:35

Is it possible to use SFML in a QT project?

I barely found a way to connect SFML to the Qt Creator environment at all. I was already delighted, but then I tried to push code that uses both qt and sfml into the project and nothing worked. The fact is that in order to connect sfml to qt creator, you need to change the .pro file (well, transfer the sfml folder to the right places), I wrote this there:

TEMPLATE = app
CONFIG -= qt
CONFIG += console

LIBS += -L/Users/vladimirkorsunov/QtProjects/untitled/untitled/Contents/Frameworks/

CONFIG (release, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-window -lsfml-system
CONFIG (debug, debug|release): LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-window -lsfml-system

INCLUDEPATH += /Users/vladimirkorsunov/QtProjects/untitled/
DEPENDPATH += /Users/vladimirkorsunov/QtProjects/untitled/

At the same time, of course, only the sfml library will work, that is, there is no particular point in this at all, because you can do this on xcode as well. I would like both qt and sfml to work, so that, for example, draw graphics on sfml, and the interface on qt, is this possible at all? I just tried to change the .pro file in different ways, either qt or sfml stops working all the time. I just don’t really understand what kind of language is in this file in general, I myself won’t figure it out for sure.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ananiev, 2021-07-20
@SaNNy32

This is where you disable Qt
CONFIG -= qt
If you need Qt libraries, then this line should be removed and added something like (depending on which modules you need)
QT += core gui widgets network
Next, SFML is connected as a regular static or dynamic library.
In INCLUDEPATH you specify the path to the *.h files of the library. In LIBS you specify which libraries will be linked against. Don't forget that if you don't specify link paths in LIBS, they must be specified in QMAKE_LIBDIR.

J
Jacob E, 2021-07-19
@Zifix

I just don’t really understand what kind of language is in this file in general, I myself won’t figure it out for sure.

Pay someone who understands.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question