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

Author Topic: Qt5 window and SFML2  (Read 3388 times)

0 Members and 1 Guest are viewing this topic.

xarxer

  • Newbie
  • *
  • Posts: 35
    • View Profile
Qt5 window and SFML2
« on: May 22, 2013, 08:30:22 am »
Hi all!

I'm trying to create a Qt application with an SFML canvas as described in the 1.6 tutorial, and it works great under Linux.

However, when compiling on Windows, I get this:

Quote
Code:
sf::RenderWindow::create(winId());

Compile routput:
'void sf::Window::create(sf::WindowHandle,const sf::ContextSettings &)' : cannot convert parameter 1 from 'WId' to 'sf::WindowHandle'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Qt5's winId() function returns what in the Qt world is refered to as quintptr (See: qwindowdefs.h)

Has anyone found a solution to this? Is there just a cast missing?

Thanks in advance  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Qt5 window and SFML2
« Reply #1 on: May 22, 2013, 08:35:32 am »
Try with a reinterpret_cast.

But Qt5 is more complex to work with. They changed their internal rendering pipeline (everything is drawn with OpenGL), and you're not supposed to get an OS handle when you call widget->winId(). If it works out of the box then you're lucky, if not, you'll have to deal with QWindow and the QPA classes.
Laurent Gomila - SFML developer

xarxer

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Qt5 window and SFML2
« Reply #2 on: May 22, 2013, 08:38:50 am »
Hi, thanks for the answer!

reinterpret_cast<sf::WindowHandle>(winId()); does not work, any other cast ideas?

It works out of the box for Linux, but not Windows.
Why am I not supposed to get an OS handle with winId()?

Thanks!

xarxer

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Qt5 window and SFML2
« Reply #3 on: May 22, 2013, 08:44:06 am »
Hi, thanks for the answer!

reinterpret_cast<sf::WindowHandle>(winId()); does not work, any other cast ideas?

It works out of the box for Linux, but not Windows.
Why am I not supposed to get an OS handle with winId()?

Thanks!

Hold on! Actually reinterpret_cast<sf::WindowHandl>(winId()); works just fine!

 

anything