Including private Qt headers is not recommended. Doing so is presumably the only way to make X11 features available in Qt6, but is this really a good idea? Is Qt6 ever likely to make these publicly available?
Indeed it's not a good idea but no other idea for the moment. We will see when we will release kf6 if we have more idea, more class etc.
As only QX11Info::connection() is used here, QNativeInterface::QX11Application::connection() might be a viable replacement. But yes, the whole situation around the former Q[X11|Android|...]Extras modules is rather unfortunate still.