Pages
API Documentation
On this page

KPasswordLineEdit Class

A lineedit which allows to display password. More...

  • Header: #include <KPasswordLineEdit>
  • CMake: find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
    target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons)
  • Inherits: QWidget

List of all members, including inherited members
Deprecated members

Properties

Public Functions

Signals

Detailed Description

Usage Example:

Get password

KPasswordLineEdit *passwordLineEdit = new KPasswordLineEdit(parent);
QString password = passwordLineEdit->password();

Property Documentation

clearButtonEnabled : bool

Access functions:

echoMode : QLineEdit::EchoMode

Access functions:

Notifier signal:

password : QString

Access functions:

Notifier signal:

Member Function Documentation

[explicit] KPasswordLineEdit::KPasswordLineEdit(QWidget *parent = nullptr)

Constructs a lineedit password widget.

parent Passed to lower level constructor.

void KPasswordLineEdit::clear()

Clear text

QLineEdit::EchoMode KPasswordLineEdit::echoMode() const

Return echo mode

Note: Getter function for property echoMode.

See also setEchoMode()

[signal] void KPasswordLineEdit::echoModeChanged(QLineEdit::EchoMode echoMode)

When we click on visibility icon echo mode is switched between Normal echo mode and Password echo mode

Note: Notifier signal for property echoMode.

bool KPasswordLineEdit::isClearButtonEnabled() const

Inform if we show or not clear button

Note: Getter function for property clearButtonEnabled.

[since 6.0] bool KPasswordLineEdit::isReadOnly() const

Return whether the line edit is read only.

This function was introduced in Qt 6.0.

QLineEdit *KPasswordLineEdit::lineEdit() const

Returns the lineedit widget.

QString KPasswordLineEdit::password() const

Returns the password entered.

Note: Getter function for property password.

See also setPassword()

[signal] void KPasswordLineEdit::passwordChanged(const QString &password)

Note: Notifier signal for property password.

[since 6.0] KPassword::RevealMode KPasswordLineEdit::revealPasswordMode() const

Return when the reveal password button is visible.

This function was introduced in Qt 6.0.

See also setRevealPasswordMode()

void KPasswordLineEdit::setClearButtonEnabled(bool clear)

Show/hide clear button (false by default)

Note: Setter function for property clearButtonEnabled.

See also isClearButtonEnabled()

void KPasswordLineEdit::setEchoMode(QLineEdit::EchoMode mode)

Change echo mode (QLineEdit::Password by default)

Note: Setter function for property echoMode.

See also echoMode()

void KPasswordLineEdit::setPassword(const QString &password)

Assign password

Note: Setter function for property password.

See also password()

[since 6.0] void KPasswordLineEdit::setReadOnly(bool readOnly)

Set whether the line edit is read only.

This function was introduced in Qt 6.0.

See also isReadOnly()

[since 6.0] void KPasswordLineEdit::setRevealPasswordMode(KPassword::RevealMode revealPasswordMode)

Set when the reveal password button will be visible.

The default is RevealPasswordMode::OnlyNew and the reveal password button will only be visible when entering a new password.

This can be used to honor the lineedit_reveal_password kiosk key, for example:

if (KAuthorized::authorize(QStringLiteral("lineedit_reveal_password"))) {
    passwordLineEdit.setRevealPasswordMode(KPasswordLineEdit::RevealPasswordMode::OnlyNew);
} else {
    passwordLineEdit.setRevealPasswordMode(KPasswordLineEdit::RevealPasswordMode::Never);
}

This function was introduced in Qt 6.0.

See also revealPasswordMode()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.