Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QItemSelectionModel Class Reference
[QtGui module]

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

 #include <QItemSelectionModel>

Inherits QObject.

Public Types

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • virtual void clear ()
  • virtual void reset ()
  • virtual void select ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command )
  • virtual void select ( const QItemSelection & selection, QItemSelectionModel::SelectionFlags command )
  • void setCurrentIndex ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command )
  • 1 public slot inherited from QObject

Signals

  • void currentChanged ( const QModelIndex & current, const QModelIndex & previous )
  • void currentColumnChanged ( const QModelIndex & current, const QModelIndex & previous )
  • void currentRowChanged ( const QModelIndex & current, const QModelIndex & previous )
  • void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )

Protected Functions

  • void emitSelectionChanged ( const QItemSelection & newSelection, const QItemSelection & oldSelection )
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 5 static public members inherited from QObject

Detailed Description

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 Model/View Classes and is part of Qt's 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, selectedItems() will return items from both layers.

See also Model/View Programming, QAbstractItemModel, and Chart Example.


Member Type Documentation

enum QItemSelectionModel::SelectionFlag
flags QItemSelectionModel::SelectionFlags

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

ConstantValueDescription
QItemSelectionModel::NoUpdate0x0000No selection will be made.
QItemSelectionModel::Clear0x0001The complete selection will be cleared.
QItemSelectionModel::Select0x0002All specified indexes will be selected.
QItemSelectionModel::Deselect0x0004All specified indexes will be deselected.
QItemSelectionModel::Toggle0x0008All specified indexes will be selected or deselected depending on their current state.
QItemSelectionModel::Current0x0010The current selection will be updated.
QItemSelectionModel::Rows0x0020All indexes will be expanded to span rows.
QItemSelectionModel::Columns0x0040All indexes will be expanded to span columns.
QItemSelectionModel::SelectCurrentSelect | CurrentA combination of Select and Current, provided for convenience.
QItemSelectionModel::ToggleCurrentToggle | CurrentA combination of Toggle and Current, provided for convenience.
QItemSelectionModel::ClearAndSelectClear | SelectA combination of Clear and Select, provided for convenience.

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


Member Function Documentation

QItemSelectionModel::QItemSelectionModel ( QAbstractItemModel * model )

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

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

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

QItemSelectionModel::~QItemSelectionModel ()   [virtual]

Destroys the selection model.

void QItemSelectionModel::clear ()   [virtual slot]

Clears the selection model. Emits selectionChanged() and currentChanged().

void QItemSelectionModel::clearSelection ()   [slot]

Clears the selection in the selection model. Emits selectionChanged().

This function was introduced in Qt 4.2.

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

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

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(), and selectionChanged().

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(), and setCurrentIndex().

QModelIndex QItemSelectionModel::currentIndex () const

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

See also setCurrentIndex().

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(), and setCurrentIndex().

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.

bool QItemSelectionModel::hasSelection () const

Returns true if the selection model contains any selection ranges; otherwise returns false.

This function was introduced in Qt 4.2.

bool QItemSelectionModel::isColumnSelected ( int column, const QModelIndex & parent ) 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.

bool QItemSelectionModel::isRowSelected ( int row, const QModelIndex & parent ) 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.

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

Returns true if the given model item index is selected.

const QAbstractItemModel * QItemSelectionModel::model () const

Returns the item model operated on by the selection model.

void QItemSelectionModel::reset ()   [virtual slot]

Clears the selection model. Does not emit any signals.

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

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

void QItemSelectionModel::select ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command )   [virtual slot]

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

See also QItemSelectionModel::SelectionFlags.

void QItemSelectionModel::select ( const QItemSelection & selection, QItemSelectionModel::SelectionFlags command )   [virtual slot]

This is an overloaded member function, provided for convenience.

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

See also QItemSelectionModel::SelectionFlag.

QModelIndexList QItemSelectionModel::selectedColumns ( int row = 0 ) const

Returns the indexes in the given row for columns where all rows are selected.

This function was introduced in Qt 4.2.

See also selectedIndexes() and selectedRows().

QModelIndexList QItemSelectionModel::selectedIndexes () const

Returns a list of all selected model item indexes. The list contains no duplicates, and is not sorted.

QModelIndexList QItemSelectionModel::selectedRows ( int column = 0 ) const

Returns the indexes in the given column for the rows where all columns are selected.

This function was introduced in Qt 4.2.

See also selectedIndexes() and selectedColumns().

const QItemSelection QItemSelectionModel::selection () const

Returns the selection ranges stored in the selection model.

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.

See also select() and currentChanged().

void QItemSelectionModel::setCurrentIndex ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command )   [slot]

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 currentIndex() and select().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 97
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 32
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Developer Network au hasard

Logo

Applications mobiles modernes avec Qt et QML

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web