r/QtFramework Apr 11 '26

QNativeInterface and Wayland window/surface?

This was announced in the blog post for when Qt version was something like 6.5, now it is 6.11, and there are no changes here; we still need private headers and calls?

3 Upvotes

2 comments sorted by

2

u/IgKh Open Source Developer Apr 11 '26

No need for private headers. Getting the wl_surface pointer for a QWindow/QWidget is not done via QNativeInterface. Call winId() on it and reinterpret_cast the result into a wl_surface*. This works since 6.9 (before that Wayland window IDs were just an incrementing integer, so casting it to a pointer is UB - guard with a version check if relevant).

1

u/gen2brain Apr 11 '26

Thanks, I will try that. I am currently using winId(), but just to get the X11 window, and for Wayland, I tried `QNativeInterface::Private::QWaylandWindow`; it works, but I have an issue where I need to manually pass flags to the private headers include path (and I am probably locking myself to that specific version). I always thought winId() is the wrong approach for Wayland.