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.