• 【Qt开发】常用控件--QLineEdit


    QLineEdit是单行文本编辑控件。比如用户名,密码等输入框可以使用该控件。

    所属头文件<QLineEdit>

    常用方法

    1.void setText(const QString &)

      设置编辑框文本内容

    2.void setReadOnly(bool)

      控件设置为只读模式

    3.void setPlaceholderText(const QString &)

      设置编辑框中的默认提示信息

    4.void setMaxLength(int)

       设置编辑中输入的最大长度

    5.void setEchoMode(EchoMode)

      设置编辑框的输入模式

      QLineEdit::Normal:默认模式,输入与现实一致

      QLineEdit::Password:密码模式,输入的内容用黑点代替,无法看到输入的内容  

      

      QLineEdit::PasswordEchoOnEdit:编辑时内容可现实,否则为密码模式

      QLineEdit::NoEcho:输入不可见

    6.void setAlignment(Qt::Alignment flag)

      设置文本显示位置

      Qt::AlignLeft:文本在左侧

      Qt::AlignCenter:文本在居中

      Qt::AlignRight:文本在右侧

    7.void setClearButtonEnabled(bool enable)

      添加清楚按钮

      显示效果为:

      

    8.void QLineEdit::setValidator(const QValidator *v)

      对输入的内容进行限制

      setValidator(0):无限制

      setValidator(new QIntValidator(this)):只能输入整数

    常用信号

     1.void textChanged(const QString &text)

      文本变化时发出信号

     2.void returnPressed(); 

      光标在输入框,按回车键发出信号

     

  • 相关阅读:
    hbase shell-namespace(命名空间指令)
    hbase shell-general(常规指令)
    hbase shell概述
    Codeforces Round #412 div2 ABCD
    Educational Codeforces Round 19
    CSU 1786 莫队+KDTree
    cdq分治入门and持续学习orz
    VK Cup 2017
    HRBUST 2072 树上求最大异或路径值
    UvaLive 5811 概率DP
  • 原文地址:https://www.cnblogs.com/woniu201/p/10672197.html
Copyright © 2020-2023  润新知