[Interest] How can I use Qt5 in my own mainloop?

POIRIER Mathieu mathieu.poirier at enac.fr
Mon Sep 29 10:52:00 CEST 2014


Hello everyone,

I'm trying to integrate Qt5 in my own mainloop.
before, using Qt4, I had installed a hook on X Display such as (from InitQtEvents()) :

QApplication* QtApp;
 
Display*
HookXDpy (XDpy* xd, XEventProc p)
{
  if (!xd)
    xd = XDefaultDpy;
  if (!xd)
    return 0;
  xd->evproc = p;
  return xd->dpy;
}
 
static void
HandleXDpyEvents (XEvent* event)
{
    QtApp->x11ProcessEvent (event);
}
 
void
InitQtEvents ()
{
  Display* dpy;
 
  if (QtApp)
    return;
 
  /* Qt app creation, with our own X11 server connection so that
     we can handle the connection in our main loop
   */
  dpy = HookXDpy (0, HandleXDpyEvents);
  QtApp = new QApplication (dpy);
}

I had created the hook and give the X11 connection to Qt4 application and then process XEvent.

How can i do this in Qt5 ?

because it seems that QXcbEventReader opens a connection on the same X11 socket (IN another thread) AND eats every xevents sent, starving my connection which receives nothing anymore, and to send them back to it-self as PostedEvents !

What should I do now to get all xevent in my own mainloop and process them if necessary to QApplications?

I haved already tried to:

reimplemented QcoreApplication::notify() but I don’t receive any native Events, for exemple: when i try to resize my QFrame .. so it doesn’t repaint itself anymore.
added NativeEventFilter and EventFilter on my QApp but it’s the same as above … I do not receive any interesting events
Any advice will be nice.
thank you.

POIRIER Mathieu
Research Engineer CHI at ENAC



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140929/ee7eb6f1/attachment.html>


More information about the Interest mailing list