如何为 QTextEdit 设置 PlaceHolderText

New*_*oon 6 qt4 qtextedit qt4.7

我想设置 a 的占位符文本QTextEdit。我知道如何为 a 设置它QLineEdit有一个属性setPlaceHolderText。但此属性不适用于QTextEdit。请提出您宝贵的建议以解决此问题。

Sca*_*ode 3

使用QTextEdit的setTextCursor(QTextCursor&)函数。使用以下逻辑。

  QTextCursor textCursor;
  textCursor.setPosistion(0, QTextCursor::MoveAnchor); 
  textedit->setTextCursor( textCursor );
Run Code Online (Sandbox Code Playgroud)

  • 你实际上是怎么做到的? (2认同)