Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QItemSelectionModel Class Reference

[38] More...

#include <qitemselectionmodel.h>

+ Inheritance diagram for QItemSelectionModel:
+ Collaboration diagram for QItemSelectionModel:

Public Types

enum  SelectionFlag {
  NoUpdate = 0x0000 , Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 ,
  Toggle = 0x0008 , Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 ,
  SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 ,
  Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 ,
  Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current ,
  ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 , Clear = 0x0001 ,
  Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 , Current = 0x0010 ,
  Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current ,
  ClearAndSelect = Clear | Select
}
 This enum describes the way the selection model will be updated. More...
 
enum  SelectionFlag {
  NoUpdate = 0x0000 , Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 ,
  Toggle = 0x0008 , Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 ,
  SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 ,
  Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 ,
  Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current ,
  ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 , Clear = 0x0001 ,
  Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 , Current = 0x0010 ,
  Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current ,
  ClearAndSelect = Clear | Select
}
 
enum  SelectionFlag {
  NoUpdate = 0x0000 , Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 ,
  Toggle = 0x0008 , Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 ,
  SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 ,
  Clear = 0x0001 , Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 ,
  Current = 0x0010 , Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current ,
  ToggleCurrent = Toggle | Current , ClearAndSelect = Clear | Select , NoUpdate = 0x0000 , Clear = 0x0001 ,
  Select = 0x0002 , Deselect = 0x0004 , Toggle = 0x0008 , Current = 0x0010 ,
  Rows = 0x0020 , Columns = 0x0040 , SelectCurrent = Select | Current , ToggleCurrent = Toggle | Current ,
  ClearAndSelect = Clear | Select
}
 

Public Slots

virtual void setCurrentIndex (const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
 Sets the model item index to be the current item, and emits currentChanged().
 
virtual void select (const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
 Selects the model item index using the specified command, and emits selectionChanged().
 
virtual void select (const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
 Selects the item selection using the specified command, and emits selectionChanged().
 
virtual void clear ()
 Clears the selection model.
 
virtual void reset ()
 Clears the selection model.
 
void clearSelection ()
 
virtual void clearCurrentIndex ()
 Clears the current index.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 This signal is emitted whenever the selection changes.
 
void currentChanged (const QModelIndex &current, const QModelIndex &previous)
 This signal is emitted whenever the current item changes.
 
void currentRowChanged (const QModelIndex &current, const QModelIndex &previous)
 This signal is emitted if the current item changes and its row is different to the row of the previous current item.
 
void currentColumnChanged (const QModelIndex &current, const QModelIndex &previous)
 This signal is emitted if the current item changes and its column is different to the column of the previous current item.
 
void modelChanged (QAbstractItemModel *model)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QItemSelectionModel (QAbstractItemModel *model=nullptr)
 Constructs a selection model that operates on the specified item model.
 
 QItemSelectionModel (QAbstractItemModel *model, QObject *parent)
 Constructs a selection model that operates on the specified item model with parent.
 
virtual ~QItemSelectionModel ()
 Destroys the selection model.
 
QModelIndex currentIndex () const
 Returns the model item index for the current item, or an invalid index if there is no current item.
 
Q_INVOKABLE bool isSelected (const QModelIndex &index) const
 Returns true if the given model item index is selected.
 
Q_INVOKABLE bool isRowSelected (int row, const QModelIndex &parent=QModelIndex()) const
 Returns true if all items are selected in the row with the given parent.
 
Q_INVOKABLE bool isColumnSelected (int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if all items are selected in the column with the given parent.
 
Q_INVOKABLE bool rowIntersectsSelection (int row, const QModelIndex &parent=QModelIndex()) const
 Returns true if there are any items selected in the row with the given parent.
 
Q_INVOKABLE bool columnIntersectsSelection (int column, const QModelIndex &parent=QModelIndex()) const
 Returns true if there are any items selected in the column with the given parent.
 
bool hasSelection () const
 
QModelIndexList selectedIndexes () const
 Returns a list of all selected model item indexes.
 
Q_INVOKABLE QModelIndexList selectedRows (int column=0) const
 
Q_INVOKABLE QModelIndexList selectedColumns (int row=0) const
 
const QItemSelection selection () const
 Returns the selection ranges stored in the selection model.
 
const QAbstractItemModelmodel () const
 Returns the item model operated on by the selection model.
 
QAbstractItemModelmodel ()
 
QBindable< QAbstractItemModel * > bindableModel ()
 
void setModel (QAbstractItemModel *model)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

 QItemSelectionModel (QItemSelectionModelPrivate &dd, QAbstractItemModel *model)
 
void emitSelectionChanged (const QItemSelection &newSelection, const QItemSelection &oldSelection)
 Compares the two selections newSelection and oldSelection and emits selectionChanged() with the deselected and selected items.
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

QAbstractItemModelmodel
 
bool hasSelection
 
QModelIndex currentIndex
 
QItemSelection selection
 
QModelIndexList selectedIndexes
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

[38]

\inmodule QtCore

[39]

The QItemSelectionModel class keeps track of a view's selected items.

A QItemSelectionModel keeps track of the selected items in a view, or in several views onto the same model. It also keeps track of the currently selected item in a view.

The QItemSelectionModel class is one of the \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{model/view framework}.

The selected items are stored using ranges. Whenever you want to modify the selected items use select() and provide either a QItemSelection, or a QModelIndex and a QItemSelectionModel::SelectionFlag.

The QItemSelectionModel takes a two layer approach to selection management, dealing with both selected items that have been committed and items that are part of the current selection. The current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).

To update the currently selected items, use the bitwise OR of QItemSelectionModel::Current and any of the other SelectionFlags. If you omit the QItemSelectionModel::Current command, a new current selection will be created, and the previous one added to the whole selection. All functions operate on both layers; for example, \l {QTableWidget::selectedItems()}{selecteditems()} will return items from both layers.

Note
Since 5.5, \l{QItemSelectionModel::model()}{model}, \l{QItemSelectionModel::hasSelection()}{hasSelection}, and \l{QItemSelectionModel::currentIndex()}{currentIndex} are meta-object properties.
See also
{Model/View Programming}, QAbstractItemModel

Definition at line 327 of file src_corelib_kernel_qobject.cpp.

Member Enumeration Documentation

◆ SelectionFlag [1/3]

This enum describes the way the selection model will be updated.

\value NoUpdate No selection will be made. \value Clear The complete selection will be cleared. \value Select All specified indexes will be selected. \value Deselect All specified indexes will be deselected. \value Toggle All specified indexes will be selected or deselected depending on their current state. \value Current The current selection will be updated. \value Rows All indexes will be expanded to span rows. \value Columns All indexes will be expanded to span columns. \value SelectCurrent A combination of Select and Current, provided for convenience. \value ToggleCurrent A combination of Toggle and Current, provided for convenience. \value ClearAndSelect A combination of Clear and Select, provided for convenience.

Enumerator
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 

Definition at line 333 of file src_corelib_kernel_qobject.cpp.

◆ SelectionFlag [2/3]

Enumerator
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 

Definition at line 333 of file src_corelib_kernel_qobject.cpp.

◆ SelectionFlag [3/3]

Enumerator
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 
NoUpdate 
Clear 
Select 
Deselect 
Toggle 
Current 
Rows 
Columns 
SelectCurrent 
ToggleCurrent 
ClearAndSelect 

Definition at line 106 of file qitemselectionmodel.h.

Constructor & Destructor Documentation

◆ QItemSelectionModel() [1/3]

QItemSelectionModel::QItemSelectionModel ( QAbstractItemModel * model = nullptr)
explicit

Constructs a selection model that operates on the specified item model.

Definition at line 1179 of file qitemselectionmodel.cpp.

◆ QItemSelectionModel() [2/3]

QItemSelectionModel::QItemSelectionModel ( QAbstractItemModel * model,
QObject * parent )
explicit

Constructs a selection model that operates on the specified item model with parent.

Definition at line 1188 of file qitemselectionmodel.cpp.

◆ ~QItemSelectionModel()

QItemSelectionModel::~QItemSelectionModel ( )
virtual

Destroys the selection model.

Definition at line 1206 of file qitemselectionmodel.cpp.

◆ QItemSelectionModel() [3/3]

QItemSelectionModel::QItemSelectionModel ( QItemSelectionModelPrivate & dd,
QAbstractItemModel * model )
protected

Definition at line 1197 of file qitemselectionmodel.cpp.

Member Function Documentation

◆ bindableModel()

QBindable< QAbstractItemModel * > QItemSelectionModel::bindableModel ( )

Definition at line 1937 of file qitemselectionmodel.cpp.

◆ clear

void QItemSelectionModel::clear ( )
virtualslot

Clears the selection model.

Emits selectionChanged() and currentChanged().

Definition at line 1378 of file qitemselectionmodel.cpp.

◆ clearCurrentIndex

void QItemSelectionModel::clearCurrentIndex ( )
virtualslot

Clears the current index.

Emits currentChanged().

Definition at line 1387 of file qitemselectionmodel.cpp.

◆ clearSelection

void QItemSelectionModel::clearSelection ( )
slot
Since
4.2 Clears the selection in the selection model. Emits selectionChanged().

Definition at line 1412 of file qitemselectionmodel.cpp.

◆ columnIntersectsSelection()

bool QItemSelectionModel::columnIntersectsSelection ( int column,
const QModelIndex & parent = QModelIndex() ) const

Returns true if there are any items selected in the column with the given parent.

Note
Since Qt 5.15, the default argument for parent is an empty model index.

Definition at line 1712 of file qitemselectionmodel.cpp.

◆ currentChanged

void QItemSelectionModel::currentChanged ( const QModelIndex & current,
const QModelIndex & previous )
signal

This signal is emitted whenever the current item changes.

The previous model item index is replaced by the current index as the selection's current item.

Note that this signal will not be emitted when the item model is reset.

See also
currentIndex(), setCurrentIndex(), selectionChanged()

◆ currentColumnChanged

void QItemSelectionModel::currentColumnChanged ( const QModelIndex & current,
const QModelIndex & previous )
signal

This signal is emitted if the current item changes and its column is different to the column of the previous current item.

Note that this signal will not be emitted when the item model is reset.

See also
currentChanged(), currentRowChanged(), currentIndex(), setCurrentIndex()

◆ currentIndex()

QModelIndex QItemSelectionModel::currentIndex ( ) const

Returns the model item index for the current item, or an invalid index if there is no current item.

Definition at line 1461 of file qitemselectionmodel.cpp.

◆ currentRowChanged

void QItemSelectionModel::currentRowChanged ( const QModelIndex & current,
const QModelIndex & previous )
signal

This signal is emitted if the current item changes and its row is different to the row of the previous current item.

Note that this signal will not be emitted when the item model is reset.

See also
currentChanged(), currentColumnChanged(), currentIndex(), setCurrentIndex()

◆ emitSelectionChanged()

void QItemSelectionModel::emitSelectionChanged ( const QItemSelection & newSelection,
const QItemSelection & oldSelection )
protected

Compares the two selections newSelection and oldSelection and emits selectionChanged() with the deselected and selected items.

Definition at line 1963 of file qitemselectionmodel.cpp.

◆ hasSelection()

bool QItemSelectionModel::hasSelection ( ) const
Since
4.2

Returns true if the selection model contains any selected item, otherwise returns false.

Definition at line 1760 of file qitemselectionmodel.cpp.

◆ isColumnSelected()

bool QItemSelectionModel::isColumnSelected ( int column,
const QModelIndex & parent = QModelIndex() ) const

Returns true if all items are selected in the column with the given parent.

Note that this function is usually faster than calling isSelected() on all items in the same column and that unselectable items are ignored.

Note
Since Qt 5.15, the default argument for parent is an empty model index.

Definition at line 1594 of file qitemselectionmodel.cpp.

◆ isRowSelected()

bool QItemSelectionModel::isRowSelected ( int row,
const QModelIndex & parent = QModelIndex() ) const

Returns true if all items are selected in the row with the given parent.

Note that this function is usually faster than calling isSelected() on all items in the same row and that unselectable items are ignored.

Note
Since Qt 5.15, the default argument for parent is an empty model index.

Definition at line 1508 of file qitemselectionmodel.cpp.

◆ isSelected()

bool QItemSelectionModel::isSelected ( const QModelIndex & index) const

Returns true if the given model item index is selected.

Definition at line 1469 of file qitemselectionmodel.cpp.

◆ model() [1/2]

QAbstractItemModel * QItemSelectionModel::model ( )

◆ model() [2/2]

const QAbstractItemModel * QItemSelectionModel::model ( ) const

Returns the item model operated on by the selection model.

Definition at line 1932 of file qitemselectionmodel.cpp.

◆ modelChanged

void QItemSelectionModel::modelChanged ( QAbstractItemModel * model)
signal
Since
5.5

This signal is emitted when the model is successfully set with setModel().

See also
model(), setModel()

◆ reset

void QItemSelectionModel::reset ( )
virtualslot

Clears the selection model.

Does not emit any signals.

Definition at line 1402 of file qitemselectionmodel.cpp.

◆ rowIntersectsSelection()

bool QItemSelectionModel::rowIntersectsSelection ( int row,
const QModelIndex & parent = QModelIndex() ) const

Returns true if there are any items selected in the row with the given parent.

Note
Since Qt 5.15, the default argument for parent is an empty model index.

Definition at line 1676 of file qitemselectionmodel.cpp.

◆ select [1/2]

void QItemSelectionModel::select ( const QItemSelection & selection,
QItemSelectionModel::SelectionFlags command )
virtualslot

Selects the item selection using the specified command, and emits selectionChanged().

See also
QItemSelectionModel::SelectionFlag

Definition at line 1327 of file qitemselectionmodel.cpp.

◆ select [2/2]

void QItemSelectionModel::select ( const QModelIndex & index,
QItemSelectionModel::SelectionFlags command )
virtualslot

Selects the model item index using the specified command, and emits selectionChanged().

See also
QItemSelectionModel::SelectionFlags

Definition at line 1216 of file qitemselectionmodel.cpp.

◆ selectedColumns()

QModelIndexList QItemSelectionModel::selectedColumns ( int row = 0) const
Since
4.2 Returns the indexes in the given row for columns where all rows are selected.
See also
selectedIndexes(), selectedRows()

Definition at line 1853 of file qitemselectionmodel.cpp.

◆ selectedIndexes()

QModelIndexList QItemSelectionModel::selectedIndexes ( ) const

Returns a list of all selected model item indexes.

The list contains no duplicates, and is not sorted.

Definition at line 1790 of file qitemselectionmodel.cpp.

◆ selectedRows()

QModelIndexList QItemSelectionModel::selectedRows ( int column = 0) const
Since
4.2 Returns the indexes in the given column for the rows where all columns are selected.
See also
selectedIndexes(), selectedColumns()

Definition at line 1824 of file qitemselectionmodel.cpp.

◆ selection()

const QItemSelection QItemSelectionModel::selection ( ) const

Returns the selection ranges stored in the selection model.

Definition at line 1878 of file qitemselectionmodel.cpp.

◆ selectionChanged

void QItemSelectionModel::selectionChanged ( const QItemSelection & selected,
const QItemSelection & deselected )
signal

This signal is emitted whenever the selection changes.

The change in the selection is represented as an item selection of deselected items and an item selection of selected items.

Note the that the current index changes independently from the selection. Also note that this signal will not be emitted when the item model is reset.

Items which stay selected but change their index are not included in selected and deselected. Thus, this signal might be emitted with both selected and deselected empty, if only the indices of selected items change.

See also
select(), currentChanged()

◆ setCurrentIndex

void QItemSelectionModel::setCurrentIndex ( const QModelIndex & index,
QItemSelectionModel::SelectionFlags command )
virtualslot

Sets the model item index to be the current item, and emits currentChanged().

The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.

Depending on the specified command, the index can also become part of the current selection.

See also
select()

Definition at line 1432 of file qitemselectionmodel.cpp.

◆ setModel()

void QItemSelectionModel::setModel ( QAbstractItemModel * model)
Since
5.5

Sets the model to model. The modelChanged() signal will be emitted.

See also
model(), modelChanged()

Definition at line 1949 of file qitemselectionmodel.cpp.

Property Documentation

◆ currentIndex

QModelIndex QItemSelectionModel::currentIndex
read
Since
5.5

Definition at line 95 of file qitemselectionmodel.h.

◆ hasSelection

bool QItemSelectionModel::hasSelection
read
Since
5.5

Definition at line 93 of file qitemselectionmodel.h.

◆ model

QAbstractItemModel * QItemSelectionModel::model
readwrite
Since
5.5
Since
5.5

Returns the item model operated on by the selection model.

Definition at line 91 of file qitemselectionmodel.h.

◆ selectedIndexes

QModelIndexList QItemSelectionModel::selectedIndexes
read
Since
5.5

Definition at line 99 of file qitemselectionmodel.h.

◆ selection

QItemSelection QItemSelectionModel::selection
read
Since
5.5

Definition at line 97 of file qitemselectionmodel.h.


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