您尚未登录。

楼主 #1 2017-10-18 10:52:32

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Qt的QLineEdit编辑框如何实现github那种提示文字效果?

20171018104950.png
如图





在线

#2 2017-10-18 10:54:14

沉鱼
管理员
注册时间: 2017-09-06
已发帖子: 161
积分: 161

Re: Qt的QLineEdit编辑框如何实现github那种提示文字效果?

这么巧,刚好我也在做这个,刚刚找到一个帖,QLineEdit本来就有接口,挺不错的。
Qt考虑很周全.

ui->lineEdit->setPlaceholderText(QString::fromStdWString("请输入账号"));


参考: https://stackoverflow.com/questions/10680535/qlineedit-with-some-default-text-for-which-cursor-should-not-be-moved

离线

#3 2017-10-18 23:09:17

沉鱼
管理员
注册时间: 2017-09-06
已发帖子: 161
积分: 161

Re: Qt的QLineEdit编辑框如何实现github那种提示文字效果?

沉鱼 说:

这么巧,刚好我也在做这个,刚刚找到一个帖,QLineEdit本来就有接口,挺不错的。
Qt考虑很周全.

ui->lineEdit->setPlaceholderText(QString::fromStdWString("请输入账号"));


参考: https://stackoverflow.com/questions/10680535/qlineedit-with-some-default-text-for-which-cursor-should-not-be-moved

我就是这么用的,
不过要Qt 5.0 之后的版本才支持,
4.xx 没这个功能

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn