문제

I want to be able to add a line of (grey) text that when you type in the line edit, goes away. So the text is not actually there, it is just displayed.

For example:
Before I type something, the grey background text is there:
http://i.imgur.com/dcXISZq.png

After I type something, the text goes away, replaced by the text entered:
http://i.imgur.com/wfmvUsx.png

도움이 되었습니까?

해결책

void QLineEdit::setPlaceholderText( const QString & ) is what you are looking for:

Ex:

ui->lineEdit->setPlaceholderText(QString("Type here"));

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top