您的位置:首页 > 编程语言 > Qt开发

qt获取光标位置

2015-05-15 17:49 1201 查看
在写qt本版的IM软件时 想要实现@功能,需要获取输入@时的光标坐标(像素坐标);

直接上代码;

const QInputMethod *inputMethod = qApp->inputMethod();
QRect cursorRectangle = inputMethod->cursorRectangle().toRect();
int x = cursorRectangle.x();
int y = cursorRectangle.y();

效果图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: