本页内容

Utils::FancyLineEdit Class

class Utils::FancyLineEdit

FancyLineEdit 类是一个功能增强的行编辑控件,具有多项可选功能。更多内容...

Header: #include <FancyLineEdit>
Inherits: Utils::CompletingLineEdit
Inherited By:

Utils::ClassNameValidatingLineEdit and Utils::FileNameValidatingLineEdit

公共函数

void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &fn)

静态公共成员

Utils::FancyLineEdit::ValidationFunction defaultValidationFunction()

详细说明

一个 FancyLineEdit 实例可以包含:

  • 一侧嵌有一个与菜单相连的位图。
  • 当未获得焦点且为空时,会显示一个灰色的提示文本(如“请在此处输入”)。在连接到“已更改”信号并查询文本时,需注意:如果 isShowingHintText() 返回 true(即不包含有效的用户输入),则文本将被设置为该提示文本。
  • 历史记录补全功能。
  • 通过设置validationFunction 来验证文本字段内容的能力。

当内容无效时,文本颜色将变为红色,且工具提示中会显示错误信息。与会阻止用户输入某些字符的QValidator 相比,这种方法对用户的干扰较小。

可见的提示文本会导致验证处于“DisplayingInitialText”状态,该状态虽无效,但不会被标记为红色。

成员函数文档

[static] Utils::FancyLineEdit::ValidationFunction FancyLineEdit::defaultValidationFunction()

返回默认的验证函数,该函数会同步执行行编辑控件的验证器。

另请参阅 ` setValidationFunction()`。

void FancyLineEdit::setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &fn)

设置一个同步或异步的验证函数fn 。异步验证函数在FancyLineEdit 实例销毁后仍可继续运行。在关闭过程中,异步验证函数可继续运行直至插件实例被删除之前(此时插件管理器会等待它们完成后再继续)。

另请参阅 defaultValidationFunction()。

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.