如何为QTextEdit设置PlaceHolderText [英] How to set the PlaceHolderText for QTextEdit

查看:939
本文介绍了如何为QTextEdit设置PlaceHolderText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想为 QTextEdit 设置 PlaceHolderText .我知道如何为 QLineEdit 设置它.有一个属性,用于QLineEdit的 setPlaceHolderText .但是此属性不适用于QTextEdit.请提供您宝贵的建议以解决此问题.

I just want to set a PlaceHolderText for a QTextEdit. I know how to set it for a QLineEdit. There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this.

推荐答案

使用 setTextCursor (QTextCursor&)功能.使用以下逻辑.

Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic.

  QTextCursor textCursor;
  textCursor.setPosistion(0, QTextCursor::MoveAnchor); 
  textedit->setTextCursor( textCursor );

这篇关于如何为QTextEdit设置PlaceHolderText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆