[英]How to change the text of a QLineEdit when the user click on the QLineEdit in Qt?
I have a QLineEdit
with the text "Search contents..." . 我有一个
QLineEdit
,其文本为“搜索内容...” 。
I would like when QLineEdit
has the focus or when the cursor go inside the text that the text is set to an empty string. 我
QLineEdit
拥有焦点时或当光标移到文本内时,将文本设置为空字符串。 [This works: I have no problem, I used the cursorPositionChanged
signal of QLineEdit
]. [这有效:我没问题,我使用了
QLineEdit
的cursorPositionChanged
信号]。
I would like also when the QLineEdit
leaves the focus and if the text is empty that the text of the QLineEdit
is set to "Search contents..." . 我也
QLineEdit
离开焦点时,如果文本为空,则QLineEdit
的文本设置为“ Search contents ...” 。 [I don't know how to do that]. [我不知道该怎么做]。
QLineEdit
的placeholderText
属性正是您所需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.