问题
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
or about the text caret
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