How to set cursor shape to '>' in a QTextEdit?

天涯浪子 提交于 2021-02-16 14:30:27

问题


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?


回答1:


You need to set the QTextEdit's viewport's cursor: http://doc.qt.nokia.com/stable/qtextedit.html

"The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. It can be changed through the viewport()'s cursor property."

e.g. To hide the cursor completely:

ui.textEdit->viewport()->setCursor(Qt::BlankCursor);



回答2:


are you talking about mouse's shape enter image description here

or about the text caret enter image description here

Check QTextLayout::drawCursor




回答3:


You may think you want to do this, but you really don't. What will it gain you to change the mouse cursor to '>'? It will certainly confuse the user.



来源:https://stackoverflow.com/questions/5269606/how-to-set-cursor-shape-to-in-a-qtextedit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!