You could use the wayland-client library like this before your instantiate your QApplication:
#include <QApplication>
#include <wayland-client.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
struct wl_display *display = NULL;
while(!display)
{
// Return NULL if no compositor avaliable in wayland-0
display = wl_display_connect(NULL);
// Wait 200 ms so you dont overuse your CPU
usleep(200000);
}
// Disconnect because QApplication will stablish its own connection
wl_display_disconnect(display);
// Start the app
QApplication app(argc,argv);
...
}
Its a bit ugly but it should work.