SFML community forums

Help => General => Topic started by: diego997 on February 09, 2013, 12:07:08 am

Title: QT + SFML
Post by: diego997 on February 09, 2013, 12:07:08 am
Hello, is it possible to use QT in SFML ? I mean the Game will be written in SFML and QT will take care of interface :D
Title: Re: QT + SFML
Post by: eXpl0it3r on February 09, 2013, 12:17:43 am
No and yes. ;)

You can't use Qt in SFML, but you can use SFML in Qt. That is you can have a Qt widget that will act as a sf::Window where you can render to etc. but you won't be able to place buttons etc on top of the SFML part.
So if you want a GUI that surrounds your rendering part, then go for it, but if you want something like an in-game GUI, then you could take a look at the FAQ (https://github.com/SFML/SFML/wiki/FAQ#wiki-libraries-gui-package).
Title: Re: QT + SFML
Post by: diego997 on February 09, 2013, 11:38:40 pm
Thank you for response and good explanation :)
Title: Re: QT + SFML
Post by: XeRaCKeR on May 11, 2013, 10:16:26 pm
Hi

No and yes. ;)

You can't use Qt in SFML, but you can use SFML in Qt. That is you can have a Qt widget that will act as a sf::Window where you can render to etc. but you won't be able to place buttons etc on top of the SFML part.
So if you want a GUI that surrounds your rendering part, then go for it, but if you want something like an in-game GUI, then you could take a look at the FAQ (https://github.com/SFML/SFML/wiki/FAQ#wiki-libraries-gui-package).

I'm using SFML2.0 integrated in a QWidget (Using Qt 4.8), and I'm able to place buttons and any others QWidgets over the QWidget which "inherit" the SFML texture, there is a code where I explain simply how I could do it:

SFMLV = new SFMLView(SFMLWidget, QPoint(0, 0), QSize(800, 640)); // Draw the SFML texture on the QWidget SFMLWidget
SFMLWidget->setLayout(mainLayout); // Draw mainLayout, where are some QWidgets over the SFML texture
setCentralWidget(SFMLWidget);
show(); // Show the QMainWindow

But I'm having a important problem: when I place, for example, a button on the SFML texture, it looks like this image (http://i.imgur.com/GmzZcLD.png?2), any QWidget over the SFML texture have a background which I'm able to change his colour, but I can't set it transparent (well, the background is transparent by default really, but it is like if the QWidget erase the SFML texture part which there's below, that's why the "Inventario" button and the char's name looks thus). Sorry if I couldn't explain my problem as I wish.

Another image (http://i.imgur.com/j9P9cB7.png)

I'm searching how to solve this problem since 2 days ago but I can't find the answer. :(

I know that should be posted in Qt Forums, but I think that it can be interesting to learn how to solve it.

Sorry for bad english. Regards