如何将光标形状设置为“>"在QTextEdit中? [英] How to set cursor shape to '>' in a QTextEdit?
问题描述
我正在尝试模仿命令行客户端.我希望将光标形状设置为>",以向用户显示消息.我没有在QCursor提供的选项中看到该形状.有没有办法为小部件光标设置自定义形状?
I am trying to mimic a command-line client. I wish to set the cursor shape to '>', to show messages to user. I don't see that shape in the options provided by QCursor. Is there a way to set custom shapes to widget cursors?
推荐答案
您需要设置QTextEdit的视口光标: http://doc.qt.nokia.com/stable/qtextedit.html
You need to set the QTextEdit's viewport's cursor: http://doc.qt.nokia.com/stable/qtextedit.html
默认情况下,QTextEdit上的鼠标光标的形状为Qt :: IBeamCursor.可以通过viewport()的cursor属性对其进行更改."
"The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. It can be changed through the viewport()'s cursor property."
例如要完全隐藏光标:
ui.textEdit->viewport()->setCursor(Qt::BlankCursor);
这篇关于如何将光标形状设置为“>"在QTextEdit中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!