我现在将QTextEdit与qt虚拟键盘一起使用,并且遇到QTextEdit的问题
我想禁用QTextEdit中的textcursor。我尝试使用
setCursorWidth(0);
Run Code Online (Sandbox Code Playgroud)
textcursor确实消失了。但是当我使用阿拉伯语键盘时,那里会有一个小箭头闪烁
像这样:
有什么办法可以禁用该闪烁的光标?非常感谢!
实际上这是一个 Qt bug,在这里报告。作为解决方法,您可以使用继承QTextEdit
并重新实现keyPressEvent
事件的自定义类:
class TextEdit : public QTextEdit
{
public:
TextEdit(QWidget* parent = nullptr) : QTextEdit(parent) {
setReadOnly(true);
}
void keyPressEvent(QKeyEvent* event) {
setReadOnly(false);
QTextEdit::keyPressEvent(event);
setReadOnly(true);
}
};
Run Code Online (Sandbox Code Playgroud)
这也将隐藏从右到左语言中的光标。
归档时间: |
|
查看次数: |
285 次 |
最近记录: |