简体   繁体   中英

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..." .

  1. 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. [This works: I have no problem, I used the cursorPositionChanged signal of QLineEdit ].

  2. 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..." . [I don't know how to do that].

QLineEditplaceholderText属性正是您所需要的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM