开发者

Qt: How to send an event to the operating/window system?

I want to create an event in one Qt application that can be picked up by a seperate Qt application running at开发者_如何学编程 the same time. The normal sendevent function requires you to name the object which will receive it but I can't use that, I want it to be like a keyboard press event which filters through any open programs in the OS. Does anyone know how to do that? thanks


Take a look at Inter-Process Communication in Qt. The most cross-platform friendly way is to use a socket.

Shared memory is also an option, but for events I would recommend a socket that you can then attach slots to on the receiving side to handle it like a local event.

Edit: Sorry I think i missed the real point when I read the other answer, you want to make something like a key-logger that records strokes anywhere. Not sure about that one.


First of all - it'd be far from cross platform and cannot use Qt for this specific function. So, so answer that question, which OS are you aiming for?

Second, are you writing both applications? Why not pass your "events" through D-bus (UNIX only...), or even over XMLRPC (http://doc.libqxt.org/tip/qxtrpcservice.html), and avoid the whole faking event business?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜