Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 如何在QLineEdit中将光标向后移动一步?_Qt - Fatal编程技术网

Qt 如何在QLineEdit中将光标向后移动一步?

Qt 如何在QLineEdit中将光标向后移动一步?,qt,Qt,如何在QLineEdit中将光标向后移动一步 感谢您的帮助 我试过了 pLineEdit->cursorBackward(true,1); 但它不起作用。请查看文档: 使用cursorPosition()获取当前位置,然后使用setCursorPosition()将其向后设置一步 看一下文档: 使用cursorPosition()获取当前位置,然后使用setCursorPosition()将其向后设置一步 如果要撤消,只需调用撤消函数即可。 如果要返回一个字符,可以使用cursorBac

如何在QLineEdit中将光标向后移动一步

感谢您的帮助

我试过了

pLineEdit->cursorBackward(true,1);
但它不起作用。

请查看文档:

使用
cursorPosition()
获取当前位置,然后使用
setCursorPosition()
将其向后设置一步

看一下文档:


使用
cursorPosition()
获取当前位置,然后使用
setCursorPosition()
将其向后设置一步

如果要撤消,只需调用撤消函数即可。
如果要返回一个字符,可以使用cursorBackward。

如果要撤消,只需调用撤消函数。
如果要返回一个字符,可以使用cursorBackward。

void QLineEdit::cursorBackward(布尔标记,int steps=1)正是您想要的,请参见void QLineEdit::cursorBackward(布尔标记,int steps=1)
正是您想要的,请参见

如果
cursorBackward()
不起作用,那么
cursorPosition()
返回什么呢?如果
cursorBackward()
不起作用,那么
cursorPosition()
返回什么呢?我在pos=pLineEdit->cursorPosition()中也尝试了这个方法;pLineEdit->设置光标位置(位置-1);但它不会将文本设置为后退一步,但当我调试时,它会显示正确的光标位置。“将文本设置为后退一步”。。。你的意思是“光标”还是真的是“文本”?你是想实现退格吗?还是撤消功能?我也尝试了int pos=pLineEdit->cursorPosition();pLineEdit->设置光标位置(位置-1);但它不会将文本设置为后退一步,但当我调试时,它会显示正确的光标位置。“将文本设置为后退一步”。。。你的意思是“光标”还是真的是“文本”?你是想实现退格吗?还是撤销功能?