SFML community forums

Help => Window => Topic started by: xarxer on May 22, 2013, 08:30:22 am

Title: Qt5 window and SFML2
Post by: xarxer 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 (http://sfml-dev.org/tutorials/1.6/graphics-qt.php), 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 (http://qt.gitorious.org/qt/qtbase/blobs/stable/src/gui/kernel/qwindowdefs.h))

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

Thanks in advance  :)
Title: Re: Qt5 window and SFML2
Post by: Laurent 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.
Title: Re: Qt5 window and SFML2
Post by: xarxer 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!
Title: Re: Qt5 window and SFML2
Post by: xarxer 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!