QtBase  v6.3.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QListWidget Class Reference

The QListWidget class provides an item-based list widget. More...

#include <qlistwidget.h>

Inheritance diagram for QListWidget:
Inheritance graph
[legend]
Collaboration diagram for QListWidget:
Collaboration graph
[legend]

Public Slots

void scrollToItem (const QListWidgetItem *item, QAbstractItemView::ScrollHint hint=EnsureVisible)
 
void clear ()
 
- Public Slots inherited from QAbstractItemView
virtual void selectAll ()
 
void edit (const QModelIndex &index)
 
void clearSelection ()
 
void setCurrentIndex (const QModelIndex &index)
 
void scrollToTop ()
 
void scrollToBottom ()
 
void update (const QModelIndex &index)
 

Signals

void itemPressed (QListWidgetItem *item)
 
void itemClicked (QListWidgetItem *item)
 
void itemDoubleClicked (QListWidgetItem *item)
 
void itemActivated (QListWidgetItem *item)
 
void itemEntered (QListWidgetItem *item)
 
void itemChanged (QListWidgetItem *item)
 
void currentItemChanged (QListWidgetItem *current, QListWidgetItem *previous)
 
void currentTextChanged (const QString &currentText)
 
void currentRowChanged (int currentRow)
 
void itemSelectionChanged ()
 
- Signals inherited from QListView
void indexesMoved (const QModelIndexList &indexes)
 
- Signals inherited from QAbstractItemView
void pressed (const QModelIndex &index)
 
void clicked (const QModelIndex &index)
 
void doubleClicked (const QModelIndex &index)
 
void activated (const QModelIndex &index)
 
void entered (const QModelIndex &index)
 
void viewportEntered ()
 
void iconSizeChanged (const QSize &size)
 

Public Member Functions

 QListWidget (QWidget *parent=nullptr)
 
 ~QListWidget ()
 
void setSelectionModel (QItemSelectionModel *selectionModel) override
 
QListWidgetItemitem (int row) const
 
int row (const QListWidgetItem *item) const
 
void insertItem (int row, QListWidgetItem *item)
 
void insertItem (int row, const QString &label)
 
void insertItems (int row, const QStringList &labels)
 
void addItem (const QString &label)
 
void addItem (QListWidgetItem *item)
 
void addItems (const QStringList &labels)
 
QListWidgetItemtakeItem (int row)
 
int count () const
 
QListWidgetItemcurrentItem () const
 
void setCurrentItem (QListWidgetItem *item)
 
void setCurrentItem (QListWidgetItem *item, QItemSelectionModel::SelectionFlags command)
 
int currentRow () const
 
void setCurrentRow (int row)
 
void setCurrentRow (int row, QItemSelectionModel::SelectionFlags command)
 
QListWidgetItemitemAt (const QPoint &p) const
 
QListWidgetItemitemAt (int x, int y) const
 
QRect visualItemRect (const QListWidgetItem *item) const
 
void sortItems (Qt::SortOrder order=Qt::AscendingOrder)
 
void setSortingEnabled (bool enable)
 
bool isSortingEnabled () const
 
void editItem (QListWidgetItem *item)
 
void openPersistentEditor (QListWidgetItem *item)
 
void closePersistentEditor (QListWidgetItem *item)
 
bool isPersistentEditorOpen (QListWidgetItem *item) const
 
QWidgetitemWidget (QListWidgetItem *item) const
 
void setItemWidget (QListWidgetItem *item, QWidget *widget)
 
void removeItemWidget (QListWidgetItem *item)
 
QList< QListWidgetItem * > selectedItems () const
 
QList< QListWidgetItem * > findItems (const QString &text, Qt::MatchFlags flags) const
 
QList< QListWidgetItem * > items (const QMimeData *data) const
 
QModelIndex indexFromItem (const QListWidgetItem *item) const
 
QListWidgetItemitemFromIndex (const QModelIndex &index) const
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
- Public Member Functions inherited from QListView
 QListView (QWidget *parent=nullptr)
 
 ~QListView ()
 
void setMovement (Movement movement)
 
Movement movement () const
 
void setFlow (Flow flow)
 
Flow flow () const
 
void setWrapping (bool enable)
 
bool isWrapping () const
 
void setResizeMode (ResizeMode mode)
 
ResizeMode resizeMode () const
 
void setLayoutMode (LayoutMode mode)
 
LayoutMode layoutMode () const
 
void setSpacing (int space)
 
int spacing () const
 
void setBatchSize (int batchSize)
 
int batchSize () const
 
void setGridSize (const QSize &size)
 
QSize gridSize () const
 
void setViewMode (ViewMode mode)
 
ViewMode viewMode () const
 
void clearPropertyFlags ()
 
bool isRowHidden (int row) const
 
void setRowHidden (int row, bool hide)
 
void setModelColumn (int column)
 
int modelColumn () const
 
void setUniformItemSizes (bool enable)
 
bool uniformItemSizes () const
 
void setWordWrap (bool on)
 
bool wordWrap () const
 
void setSelectionRectVisible (bool show)
 
bool isSelectionRectVisible () const
 
void setItemAlignment (Qt::Alignment alignment)
 
Qt::Alignment itemAlignment () const
 
QRect visualRect (const QModelIndex &index) const override
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 
QModelIndex indexAt (const QPoint &p) const override
 
void doItemsLayout () override
 
void reset () override
 
void setRootIndex (const QModelIndex &index) override
 
- Public Member Functions inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 
 ~QAbstractItemView ()
 
QAbstractItemModelmodel () const
 
QItemSelectionModelselectionModel () const
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegate () const
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 
QModelIndex rootIndex () const
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
virtual void keyboardSearch (const QString &search)
 
QSize sizeHintForIndex (const QModelIndex &index) const
 
virtual int sizeHintForRow (int row) const
 
virtual int sizeHintForColumn (int column) const
 
void openPersistentEditor (const QModelIndex &index)
 
void closePersistentEditor (const QModelIndex &index)
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
QWidgetindexWidget (const QModelIndex &index) const
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 

Protected Member Functions

bool event (QEvent *e) override
 
virtual QStringList mimeTypes () const
 
virtual QMimeDatamimeData (const QList< QListWidgetItem * > &items) const
 
- Protected Member Functions inherited from QListView
 QListView (QListViewPrivate &, QWidget *parent=nullptr)
 
bool event (QEvent *e) override
 
void scrollContentsBy (int dx, int dy) override
 
void resizeContents (int width, int height)
 
QSize contentsSize () const
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) override
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override
 
void mouseMoveEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 
void timerEvent (QTimerEvent *e) override
 
void resizeEvent (QResizeEvent *e) override
 
void initViewItemOption (QStyleOptionViewItem *option) const override
 
void paintEvent (QPaintEvent *e) override
 
int horizontalOffset () const override
 
int verticalOffset () const override
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 
QRect rectForIndex (const QModelIndex &index) const
 
void setPositionForIndex (const QPoint &position, const QModelIndex &index)
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 
QModelIndexList selectedIndexes () const override
 
void updateGeometries () override
 
bool isIndexHidden (const QModelIndex &index) const override
 
void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 
void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 
QSize viewportSizeHint () const override
 
- Protected Member Functions inherited from QAbstractItemView
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 
State state () const
 
void setState (State state)
 
void scheduleDelayedItemsLayout ()
 
void executeDelayedItemsLayout ()
 
void setDirtyRegion (const QRegion &region)
 
void scrollDirtyRegion (int dx, int dy)
 
QPoint dirtyRegionOffset () const
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 
bool event (QEvent *event) override
 
bool viewportEvent (QEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void focusInEvent (QFocusEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void timerEvent (QTimerEvent *event) override
 
void inputMethodEvent (QInputMethodEvent *event) override
 
bool eventFilter (QObject *object, QEvent *event) override
 
QSize viewportSizeHint () const override
 

Properties

int count
 the number of items in the list including any hidden items. More...
 
int currentRow
 the row of the current item. More...
 
bool sortingEnabled
 whether sorting is enabled More...
 
- Properties inherited from QListView
Movement movement
 whether the items can be moved freely, are snapped to a grid, or cannot be moved at all. More...
 
Flow flow
 which direction the items layout should flow. More...
 
bool isWrapping
 whether the items layout should wrap. More...
 
ResizeMode resizeMode
 whether the items are laid out again when the view is resized. More...
 
LayoutMode layoutMode
 determines whether the layout of items should happen immediately or be delayed. More...
 
int spacing
 the space around the items in the layout More...
 
QSize gridSize
 the size of the layout grid More...
 
ViewMode viewMode
 the view mode of the QListView. More...
 
int modelColumn
 the column in the model that is visible More...
 
bool uniformItemSizes
 whether all items in the listview have the same size More...
 
int batchSize
 the number of items laid out in each batch if \l layoutMode is set to \l Batched More...
 
bool wordWrap
 the item text word-wrapping policy More...
 
bool selectionRectVisible
 if the selection rectangle should be visible More...
 
Qt::Alignment itemAlignment
 the alignment of each item in its cell More...
 
- Properties inherited from QAbstractItemView
bool autoScroll
 whether autoscrolling in drag move events is enabled More...
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered More...
 
EditTriggers editTriggers
 which actions will initiate item editing More...
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled. More...
 
bool alternatingRowColors
 whether to draw the background using alternating colors More...
 
SelectionMode selectionMode
 which selection mode the view operates in More...
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses More...
 
QSize iconSize
 the size of items' icons More...
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text. More...
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction More...
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction More...
 

Friends

class QListWidgetItem
 
class QListModel
 

Additional Inherited Members

- Public Types inherited from QListView
enum  Movement { Static , Free , Snap }
 
enum  Flow { LeftToRight , TopToBottom }
 
enum  ResizeMode { Fixed , Adjust }
 
enum  LayoutMode { SinglePass , Batched }
 
enum  ViewMode { ListMode , IconMode }
 
- Public Types inherited from QAbstractItemView
enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 
- Protected Slots inherited from QAbstractItemView
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void horizontalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 
virtual void commitData (QWidget *editor)
 
virtual void editorDestroyed (QObject *editor)
 

Detailed Description

The QListWidget class provides an item-based list widget.

\inmodule QtWidgets

QListWidget is a convenience class that provides a list view similar to the one supplied by QListView, but with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list.

For a more flexible list view widget, use the QListView class with a standard model.

List widgets are constructed in the same way as other widgets:

The selectionMode() of a list widget determines how many of the items in the list can be selected at the same time, and whether complex selections of items can be created. This can be set with the setSelectionMode() function.

There are two ways to add items to the list: they can be constructed with the list widget as their parent widget, or they can be constructed with no parent widget and added to the list later. If a list widget already exists when the items are constructed, the first method is easier to use:

If you need to insert a new item into the list at a particular position, then it should be constructed without a parent widget. The insertItem() function should then be used to place it within the list. The list widget will take ownership of the item.

For multiple items, insertItems() can be used instead. The number of items in the list is found with the count() function. To remove items from the list, use takeItem().

The current item in the list can be found with currentItem(), and changed with setCurrentItem(). The user can also change the current item by navigating with the keyboard or clicking on a different item. When the current item changes, the currentItemChanged() signal is emitted with the new current item and the item that was previously current.

See also
QListWidgetItem, QListView, QTreeView, {Model/View Programming}, {Tab Dialog Example}

Definition at line 187 of file qlistwidget.h.

Constructor & Destructor Documentation

◆ QListWidget()

QListWidget::QListWidget ( QWidget parent = nullptr)
explicit

Constructs an empty QListWidget with the given parent.

Definition at line 1405 of file qlistwidget.cpp.

◆ ~QListWidget()

QListWidget::~QListWidget ( )

Destroys the list widget and all its items.

Definition at line 1416 of file qlistwidget.cpp.

Member Function Documentation

◆ addItem() [1/2]

void QListWidget::addItem ( const QString label)
inline

Inserts an item with the text label at the end of the list widget.

Definition at line 208 of file qlistwidget.h.

Here is the caller graph for this function:

◆ addItem() [2/2]

void QListWidget::addItem ( QListWidgetItem item)
inline

Inserts the item at the end of the list widget.

Warning
A QListWidgetItem can only be added to a QListWidget once. Adding the same QListWidgetItem multiple times to a QListWidget will result in undefined behavior.
See also
insertItem()

Definition at line 300 of file qlistwidget.h.

◆ addItems()

void QListWidget::addItems ( const QStringList labels)
inline

Inserts items with the text labels at the end of the list widget.

See also
insertItems()

Definition at line 210 of file qlistwidget.h.

◆ clear

void QListWidget::clear ( )
slot

Removes all items and selections in the view.

Warning
All items will be permanently deleted.

Definition at line 1814 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closePersistentEditor()

void QListWidget::closePersistentEditor ( QListWidgetItem item)

Closes the persistent editor for the given item.

See also
openPersistentEditor(), isPersistentEditorOpen()

Definition at line 1708 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ count()

int QListWidget::count ( ) const

Definition at line 1535 of file qlistwidget.cpp.

◆ currentItem()

QListWidgetItem * QListWidget::currentItem ( ) const

Returns the current item.

Definition at line 1544 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentItemChanged

void QListWidget::currentItemChanged ( QListWidgetItem current,
QListWidgetItem previous 
)
signal

This signal is emitted whenever the current item changes.

previous is the item that previously had the focus; current is the new current item.

◆ currentRow()

int QListWidget::currentRow ( ) const

Definition at line 1578 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ currentRowChanged

void QListWidget::currentRowChanged ( int  currentRow)
signal

This signal is emitted whenever the current item changes.

currentRow is the row of the current item. If there is no current item, the currentRow is -1.

◆ currentTextChanged

void QListWidget::currentTextChanged ( const QString currentText)
signal

This signal is emitted whenever the current item changes.

currentText is the text data in the current item. If there is no current item, the currentText is invalid.

◆ editItem()

void QListWidget::editItem ( QListWidgetItem item)

Starts editing the item if it is editable.

Definition at line 1684 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ event()

bool QListWidget::event ( QEvent e)
overrideprotected

\reimp

Definition at line 1949 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ findItems()

QList< QListWidgetItem * > QListWidget::findItems ( const QString text,
Qt::MatchFlags  flags 
) const

Finds items with the text that matches the string text using the given flags.

Definition at line 1783 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ indexFromItem()

QModelIndex QListWidget::indexFromItem ( const QListWidgetItem item) const

Returns the QModelIndex associated with the given item.

Note
In Qt versions prior to 5.10, this function took a non-{const} item.

Definition at line 1920 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertItem() [1/2]

void QListWidget::insertItem ( int  row,
const QString label 
)

Inserts an item with the text label in the list widget at the position given by row.

See also
addItem()

Definition at line 1493 of file qlistwidget.cpp.

◆ insertItem() [2/2]

void QListWidget::insertItem ( int  row,
QListWidgetItem item 
)

Inserts the item at the position in the list given by row.

See also
addItem()

Definition at line 1479 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertItems()

void QListWidget::insertItems ( int  row,
const QStringList labels 
)

Inserts items from the list of labels into the list, starting at the given row.

See also
insertItem(), addItem()

Definition at line 1506 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ isPersistentEditorOpen() [1/2]

bool QAbstractItemView::isPersistentEditorOpen
Since
5.10

Returns whether a persistent editor is open for the item at index index.

See also
openPersistentEditor(), closePersistentEditor()

Definition at line 218 of file qabstractitemview.cpp.

◆ isPersistentEditorOpen() [2/2]

bool QListWidget::isPersistentEditorOpen ( QListWidgetItem item) const
Since
5.10

Returns whether a persistent editor is open for item item.

See also
openPersistentEditor(), closePersistentEditor()

Definition at line 1722 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ isSortingEnabled()

bool QListWidget::isSortingEnabled ( ) const

Definition at line 1665 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ item()

QListWidgetItem * QListWidget::item ( int  row) const

Returns the item that occupies the given row in the list if one has been set; otherwise returns \nullptr.

See also
row()

Definition at line 1452 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ itemActivated

void QListWidget::itemActivated ( QListWidgetItem item)
signal

This signal is emitted when the item is activated. The item is activated when the user clicks or double clicks on it, depending on the system configuration. It is also activated when the user presses the activation key (on Windows and X11 this is the \uicontrol Return key, on Mac OS X it is \uicontrol{Command+O}).

◆ itemAt() [1/2]

QListWidgetItem * QListWidget::itemAt ( const QPoint p) const

Returns a pointer to the item at the coordinates p. The coordinates are relative to the list widget's \l{QAbstractScrollArea::}{viewport()}.

Definition at line 1611 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ itemAt() [2/2]

QListWidgetItem * QListWidget::itemAt ( int  x,
int  y 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a pointer to the item at the coordinates (x, y). The coordinates are relative to the list widget's \l{QAbstractScrollArea::}{viewport()}.

Definition at line 303 of file qlistwidget.h.

◆ itemChanged

void QListWidget::itemChanged ( QListWidgetItem item)
signal

This signal is emitted whenever the data of item has changed.

◆ itemClicked

void QListWidget::itemClicked ( QListWidgetItem item)
signal

This signal is emitted with the specified item when a mouse button is clicked on an item in the widget.

See also
itemPressed(), itemDoubleClicked()

◆ itemDoubleClicked

void QListWidget::itemDoubleClicked ( QListWidgetItem item)
signal

This signal is emitted with the specified item when a mouse button is double clicked on an item in the widget.

See also
itemClicked(), itemPressed()

◆ itemEntered

void QListWidget::itemEntered ( QListWidgetItem item)
signal

This signal is emitted when the mouse cursor enters an item. The item is the item entered. This signal is only emitted when mouseTracking is turned on, or when a mouse button is pressed while moving into an item.

See also
QWidget::setMouseTracking()

◆ itemFromIndex()

QListWidgetItem * QListWidget::itemFromIndex ( const QModelIndex index) const

Returns a pointer to the QListWidgetItem associated with the given index.

Definition at line 1930 of file qlistwidget.cpp.

◆ itemPressed

void QListWidget::itemPressed ( QListWidgetItem item)
signal

This signal is emitted with the specified item when a mouse button is pressed on an item in the widget.

See also
itemClicked(), itemDoubleClicked()

◆ items()

QList< QListWidgetItem * > QListWidget::items ( const QMimeData data) const

Returns a list of pointers to the items contained in the data object. If the object was not created by a QListWidget in the same process, the list is empty.

Definition at line 1906 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ itemSelectionChanged

void QListWidget::itemSelectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
selectedItems(), QListWidgetItem::isSelected(), currentItemChanged()
Here is the caller graph for this function:

◆ itemWidget()

QWidget * QListWidget::itemWidget ( QListWidgetItem item) const
Since
4.1

Returns the widget displayed in the given item.

See also
setItemWidget(), removeItemWidget()

Definition at line 1736 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ mimeData()

QMimeData * QListWidget::mimeData ( const QList< QListWidgetItem * > &  items) const
protectedvirtual

Returns an object that contains a serialized description of the specified items. The format used to describe the items is obtained from the mimeTypes() function.

If the list of items is empty, \nullptr is returned instead of a serialized empty list.

Definition at line 1840 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mimeTypes()

QStringList QListWidget::mimeTypes ( ) const
protectedvirtual

Returns a list of MIME types that can be used to describe a list of listwidget items.

See also
mimeData()

Definition at line 1827 of file qlistwidget.cpp.

◆ openPersistentEditor()

void QListWidget::openPersistentEditor ( QListWidgetItem item)

Opens an editor for the given item. The editor remains open after editing.

See also
closePersistentEditor(), isPersistentEditorOpen()

Definition at line 1696 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ removeItemWidget()

void QListWidget::removeItemWidget ( QListWidgetItem item)
inline
Since
4.3

Removes the widget set on the given item.

To remove an item (row) from the list entirely, either delete the item or use takeItem().

See also
itemWidget(), setItemWidget()

Definition at line 297 of file qlistwidget.h.

◆ row()

int QListWidget::row ( const QListWidgetItem item) const

Returns the row containing the given item.

See also
item()

Definition at line 1466 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollToItem

void QListWidget::scrollToItem ( const QListWidgetItem item,
QAbstractItemView::ScrollHint  hint = EnsureVisible 
)
slot

Scrolls the view if necessary to ensure that the item is visible.

hint specifies where the item should be located after the operation.

Definition at line 1802 of file qlistwidget.cpp.

◆ selectedItems()

QList< QListWidgetItem * > QListWidget::selectedItems ( ) const

Returns a list of all selected items in the list widget.

Definition at line 1766 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ setCurrentItem() [1/2]

void QListWidget::setCurrentItem ( QListWidgetItem item)

Sets the current item to item.

Unless the selection mode is \l{QAbstractItemView::}{NoSelection}, the item is also selected.

Definition at line 1557 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ setCurrentItem() [2/2]

void QListWidget::setCurrentItem ( QListWidgetItem item,
QItemSelectionModel::SelectionFlags  command 
)
Since
4.4 Set the current item to item, using the given command.

Definition at line 1566 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ setCurrentRow() [1/2]

void QListWidget::setCurrentRow ( int  row)

Definition at line 1583 of file qlistwidget.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCurrentRow() [2/2]

void QListWidget::setCurrentRow ( int  row,
QItemSelectionModel::SelectionFlags  command 
)
Since
4.4

Sets the current row to be the given row, using the given command,

Definition at line 1600 of file qlistwidget.cpp.

◆ setItemWidget()

void QListWidget::setItemWidget ( QListWidgetItem item,
QWidget widget 
)
Since
4.1

Sets the widget to be displayed in the given item.

This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or implement a custom editor widget, use QListView and subclass QStyledItemDelegate instead.

See also
itemWidget(), removeItemWidget(), {Delegate Classes}

Definition at line 1755 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ setSelectionModel()

void QListWidget::setSelectionModel ( QItemSelectionModel selectionModel)
overridevirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 1424 of file qlistwidget.cpp.

Here is the call graph for this function:

◆ setSortingEnabled()

void QListWidget::setSortingEnabled ( bool  enable)

Definition at line 1659 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ sortItems()

void QListWidget::sortItems ( Qt::SortOrder  order = Qt::AscendingOrder)

Sorts all the items in the list widget according to the specified order.

Definition at line 1642 of file qlistwidget.cpp.

◆ takeItem()

QListWidgetItem * QListWidget::takeItem ( int  row)

Removes and returns the item from the given row in the list widget; otherwise returns \nullptr.

Items removed from a list widget will not be managed by Qt, and will need to be deleted manually.

See also
insertItem(), addItem()

Definition at line 1522 of file qlistwidget.cpp.

Here is the caller graph for this function:

◆ visualItemRect()

QRect QListWidget::visualItemRect ( const QListWidgetItem item) const

Returns the rectangle on the viewport occupied by the item at item.

Definition at line 1632 of file qlistwidget.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ QListModel

friend class QListModel
friend

Definition at line 196 of file qlistwidget.h.

◆ QListWidgetItem

friend class QListWidgetItem
friend

Definition at line 195 of file qlistwidget.h.

Property Documentation

◆ count

QListWidget::count
read

the number of items in the list including any hidden items.

Definition at line 155 of file qlistwidget.h.

◆ currentRow

QListWidget::currentRow
readwrite

the row of the current item.

Depending on the current selection mode, the row may also be selected.

Definition at line 155 of file qlistwidget.h.

◆ sortingEnabled

QListWidget::sortingEnabled
readwrite

whether sorting is enabled

Since
4.2

If this property is true, sorting is enabled for the list; if the property is false, sorting is not enabled.

The default value is false.

Definition at line 155 of file qlistwidget.h.


The documentation for this class was generated from the following files: