在Mac OS X上使用Qt的CGEvent [英] Use CGEvent with Qt on Mac Os X
本文介绍了在Mac OS X上使用Qt的CGEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了这段代码:
#include< ApplicationServices / ApplicationServices.h>
...
CGEventRef mkey = CGEventCreateKeyboardEvent(NULL,(CGKeyCode)46,true);
CGEventPost(kCGAnnotatedSessionEventTap,mkey);
CFRelease(mkey);
...
但是有一个错误:
未定义的符号:
_CGEventCreateKeyboardEvent,从:
SimuleEvent :: PressControl(QString)in simuleevent.o
_CGEventPost,引用自:
SimuleEvent :: PressControl(QString)在simuleevent.o
_CFRelease中引用:
SimuleEvent :: PressControl(QString)在simuleevent.o
我想我必须链接一个图书馆,但我不知道哪个?
谢谢
Nico
解决方案
将此行添加到.pro文件中:
LIBS + = -framework ApplicationServices
I need to simulate keyPress on my Qt application (I'm on mac Os X 10.6).
I wrote this code:
#include <ApplicationServices/ApplicationServices.h>
...
CGEventRef mkey = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)46, true);
CGEventPost(kCGAnnotatedSessionEventTap, mkey);
CFRelease(mkey);
...
But there is an error:
Undefined symbols:
"_CGEventCreateKeyboardEvent", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CGEventPost", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
"_CFRelease", referenced from:
SimuleEvent::PressControl(QString) in simuleevent.o
I think I have to link a library but I don't know which ?
Thank you
Nico
解决方案
Add this line to your .pro file:
LIBS += -framework ApplicationServices
这篇关于在Mac OS X上使用Qt的CGEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文