Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QItemSelection Class

TheQItemSelection class manages information about selected items in a model.More...

Header:#include <QItemSelection>
Inherits:QList<QItemSelectionRange>

Public Functions

QItemSelection()
QItemSelection(const QModelIndex & topLeft, const QModelIndex & bottomRight)
boolcontains(const QModelIndex & index) const
QModelIndexListindexes() const
voidmerge(const QItemSelection & other, QItemSelectionModel::SelectionFlags command)
voidselect(const QModelIndex & topLeft, const QModelIndex & bottomRight)
  • 68 public functions inherited fromQList

Static Public Members

voidsplit(const QItemSelectionRange & range, const QItemSelectionRange & other, QItemSelection * result)
  • 3 static public members inherited fromQList

Detailed Description

TheQItemSelection class manages information about selected items in a model.

AQItemSelection describes the items in a model that have been selected by the user. AQItemSelection is basically a list of selection ranges, seeQItemSelectionRange. It provides functions for creating and manipulating selections, and selecting a range of items from a model.

TheQItemSelection class is one of theModel/View Classes and is part of Qt'smodel/view framework.

An item selection can be constructed and initialized to contain a range of items from an existing model. The following example constructs a selection that contains a range of items from the givenmodel, beginning at thetopLeft, and ending at thebottomRight.

QItemSelection*selection=newQItemSelection(topLeft, bottomRight);

An empty item selection can be constructed, and later populated as required. So, if the model is going to be unavailable when we construct the item selection, we can rewrite the above code in the following way:

QItemSelection*selection=newQItemSelection();...selection->select(topLeft, bottomRight);

QItemSelection saves memory, and avoids unnecessary work, by working with selection ranges rather than recording the model item index for each item in the selection. Generally, an instance of this class will contain a list of non-overlapping selection ranges.

Usemerge() to merge one item selection into another without making overlapping ranges. Usesplit() to split one selection range into smaller ranges based on a another selection range.

See alsoModel/View Programming andQItemSelectionModel.

Member Function Documentation

QItemSelection::QItemSelection()

Constructs an empty selection.

QItemSelection::QItemSelection(constQModelIndex & topLeft, constQModelIndex & bottomRight)

Constructs an item selection that extends from the top-left model item, specified by thetopLeft index, to the bottom-right item, specified bybottomRight.

bool QItemSelection::contains(constQModelIndex & index) const

Returns true if the selection contains the givenindex; otherwise returns false.

QModelIndexList QItemSelection::indexes() const

Returns a list of model indexes that correspond to the selected items.

void QItemSelection::merge(constQItemSelection & other,QItemSelectionModel::SelectionFlags command)

Merges theother selection with thisQItemSelection using thecommand given. This method guarantees that no ranges are overlapping.

Note that onlyQItemSelectionModel::Select,QItemSelectionModel::Deselect, andQItemSelectionModel::Toggle are supported.

See alsosplit().

void QItemSelection::select(constQModelIndex & topLeft, constQModelIndex & bottomRight)

Adds the items in the range that extends from the top-left model item, specified by thetopLeft index, to the bottom-right item, specified bybottomRight to the list.

Note:topLeft andbottomRight must have the same parent.

[static]void QItemSelection::split(constQItemSelectionRange & range, constQItemSelectionRange & other,QItemSelection * result)

Splits the selectionrange using the selectionother range. Removes all items inother fromrange and puts the result inresult. This can be compared with the semantics of thesubtract operation of a set.

See alsomerge().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp