开发者

Message loop of a QWidget owned by a QThread

I am developing a Qt application in Windows that captures global keyboard input. I am using WH_KEYBOARD which loads my DLL into every processes. When a key is pressed, the hook function in the DLL would SendMessage to a QWidget in a QThread inside the application. Problem is, how do I c开发者_JAVA百科reate a QWidget in QThread and start the message loop?


Well in two words, you can't. Widgets must be owned by the main thread and none of the GUI classes are can be multithreaded. You can though send signals across threads, i.e. the solution is to communicate from your DLL to a proxy class and then send queued signals to your widget in the main thread.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜