【问题标题】:How to change the text of a QLineEdit when the user click on the QLineEdit in Qt?当用户在 Qt 中单击 QLineEdit 时如何更改 QLineEdit 的文本?
【发布时间】:2017-04-22 00:18:05
【问题描述】:

我有一个QLineEdit,上面写着“搜索内容...”

  1. 我想当QLineEdit 获得焦点或当光标进入文本内部时,文本设置为空字符串。 [这个可行:我没问题,我用QLineEditcursorPositionChanged信号]。

  2. 我还希望QLineEdit 离开焦点并且如果文本为空QLineEdit 的文本设置为“搜索内容...”。 [我不知道该怎么做]。

【问题讨论】:

标签: c++ qt


【解决方案1】:

QLineEditplaceholderText 属性正是您所需要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多