Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: QT + SFML  (Read 4485 times)

0 Members and 1 Guest are viewing this topic.

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
QT + SFML
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: QT + SFML
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: QT + SFML
« Reply #2 on: February 09, 2013, 11:38:40 pm »
Thank you for response and good explanation :)

XeRaCKeR

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: QT + SFML
« Reply #3 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.

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, 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

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
« Last Edit: May 11, 2013, 11:53:30 pm by XeRaCKeR »

 

anything