Pages
API Documentation
On this page

KEditListWidget Class

An editable listbox. More...

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

List of all members, including inherited members

Public Types

Properties

Public Functions

Signals

Detailed Description

This class provides an editable listbox, this means a listbox which is accompanied by a line edit to enter new items into the listbox and pushbuttons to add and remove items from the listbox and two buttons to move items up and down.

Member Type Documentation

enum KEditListWidget::Button

flags KEditListWidget::Buttons

Enumeration of the buttons, the listbox offers. Specify them in the constructor in the buttons parameter, or in setButtons.

Constant
KEditListWidget::Add 0x0001
KEditListWidget::Remove 0x0002
KEditListWidget::UpDown 0x0004
KEditListWidget::All `Add

The Buttons type is a typedef for QFlags<Button>. It stores an OR combination of Button values.

Property Documentation

buttons : Buttons

Access functions:

  • KEditListWidget::Buttons buttons() const
  • void setButtons(KEditListWidget::Buttons buttons)

checkAtEntering : bool

Access functions:

items : QStringList

Access functions:

  • QStringList items() const
  • void setItems(const QStringList &items)

Notifier signal:

  • void changed()

Member Function Documentation

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

Create an editable listbox.

KEditListWidget::KEditListWidget(const KEditListWidget::CustomEditor &customEditor, QWidget *parent = nullptr, bool checkAtEntering = false, KEditListWidget::Buttons buttons = All)

Constructor which allows to use a custom editing widget instead of the standard QLineEdit widget. E.g. you can use a KUrlRequester or a QComboBox as input widget. The custom editor must consist of a lineedit and optionally another widget that is used as representation. A QComboBox or a KUrlRequester have a QLineEdit as child-widget for example, so the QComboBox is used as the representation widget.

See also KUrlRequester::customEditor(), setCustomEditor

QPushButton *KEditListWidget::addButton() const

Returns a pointer to the Add button

[signal] void KEditListWidget::added(const QString &text)

This signal is emitted when the user adds a new string to the list, the parameter is the added string.

KEditListWidget::Buttons KEditListWidget::buttons() const

Returns which buttons are visible

Note: Getter function for property buttons.

See also setButtons()

bool KEditListWidget::checkAtEntering()

Returns true if check at entering is enabled.

Note: Getter function for property checkAtEntering.

See also setCheckAtEntering()

void KEditListWidget::clear()

Clears both the listbox and the line edit.

int KEditListWidget::count() const

Returns the count of elements in the list

int KEditListWidget::currentItem() const

Returns the currently selected item

QString KEditListWidget::currentText() const

Returns the currently selected item's text

QPushButton *KEditListWidget::downButton() const

Returns a pointer to the Down button

void KEditListWidget::insertItem(const QString &text, int index = -1)

Inserts a text element at the index position If index is negative, the element will be appended

void KEditListWidget::insertStringList(const QStringList &list, int index = -1)

Inserts a list of elements from the index element If index is negative, the elements will be appended

QStringList KEditListWidget::items() const

Returns a list with the text of all items in the listbox

Note: Getter function for property items.

See also setItems()

QLineEdit *KEditListWidget::lineEdit() const

Returns a pointer to the embedded QLineEdit.

QListView *KEditListWidget::listView() const

Returns a pointer to the embedded QListView.

QPushButton *KEditListWidget::removeButton() const

Returns a pointer to the Remove button

[signal] void KEditListWidget::removed(const QString &text)

This signal is emitted when the user removes a string from the list, the parameter is the removed string.

void KEditListWidget::setButtons(KEditListWidget::Buttons buttons)

Specifies which buttons are visible

Note: Setter function for property buttons.

See also buttons()

void KEditListWidget::setCheckAtEntering(bool check)

If check is true, after every character you type in the line edit KEditListWidget will enable or disable the Add-button, depending whether the current content of the line edit is already in the listbox. Maybe this can become a performance hit with large lists on slow machines.

If check is false, it will be checked if you press the Add-button. It is not possible to enter items twice into the listbox. Default is false.

Note: Setter function for property checkAtEntering.

See also checkAtEntering()

void KEditListWidget::setCustomEditor(const KEditListWidget::CustomEditor &editor)

Allows to use a custom editing widget instead of the standard QLineEdit widget. E.g. you can use a KUrlRequester or a QComboBox as input widget. The custom editor must consist of a lineedit and optionally another widget that is used as representation. A QComboBox or a KUrlRequester have a QLineEdit as child-widget for example, so the QComboBox is used as the representation widget.

void KEditListWidget::setItems(const QStringList &items)

Clears the listbox and sets the contents to items

Note: Setter function for property items.

See also items()

QString KEditListWidget::text(int index) const

Returns the text at the index position

QPushButton *KEditListWidget::upButton() const

Returns a pointer to the Up button

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