查看完整版本: [-- QLineEdit 设置光标位置 --]

QTCN开发网 -> Qt基础编程 -> QLineEdit 设置光标位置 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

nishishei 2010-12-15 23:13

QLineEdit 设置光标位置

setCursorPosition我想用这个函数设置QlineEdit的初始位置。但是根本不起作用,我把他写在paintEvent里而且要在编辑框有数据才有作用,但是我想要的要过是当没有数据时他在我需要的位置开始,并且光标不能再往前。需要用什么函数写呢。
我的方法一、前半部分用空格充当,用keyEvent截取Qt::Backespace响应,做判断,可以实现,但是有BUG,而且后期要获取数据也麻烦。请教其他办法。

nishishei 2010-12-18 16:38
大家就告诉我怎么这是光标位置就行了!!!

52beikeda 2018-03-06 14:54
nishishei:大家就告诉我怎么这是光标位置就行了!!! (2010-12-18 16:38) 

void QLineEdit::setTextMargins ( int left, int top, int right, int bottom )
设置边距。


查看完整版本: [-- QLineEdit 设置光标位置 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled