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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QItemSelection Class Reference
[QtGui module]

The QItemSelection class manages information about selected items in a model. More...

 #include <QItemSelection>

Inherits QList<QItemSelectionRange>.

Public Functions

  • QItemSelection ( const QModelIndex & topLeft, const QModelIndex & bottomRight )
  • bool contains ( const QModelIndex & index ) const
  • QModelIndexList indexes () const
  • void merge ( const QItemSelection & other, QItemSelectionModel::SelectionFlags command )
  • void select ( const QModelIndex & topLeft, const QModelIndex & bottomRight )
  • 60 public functions inherited from QList

Static Public Members

  • void split ( const QItemSelectionRange & range, const QItemSelectionRange & other, QItemSelection * result )
  • 3 static public members inherited from QList

Detailed Description

The QItemSelection class manages information about selected items in a model.

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

The QItemSelection class is one of the Model/View Classes and is part of Qt's model/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 given model, beginning at the topLeft, and ending at the bottomRight.

 QItemSelection *selection = new QItemSelection(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 = new QItemSelection();
 ...
 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.

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

See also Model/View Programming and QItemSelectionModel.


Member Function Documentation

QItemSelection::QItemSelection ()

Constructs an empty selection.

QItemSelection::QItemSelection ( const QModelIndex & topLeft, const QModelIndex & bottomRight )

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

bool QItemSelection::contains ( const QModelIndex & index ) const

Returns true if the selection contains the given index; otherwise returns false.

QModelIndexList QItemSelection::indexes () const

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

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

Merges the other selection with this QItemSelection using the command given. This method guarantees that no ranges are overlapping.

Note that only QItemSelectionModel::Select, QItemSelectionModel::Deselect, and QItemSelectionModel::Toggle are supported.

See also split().

void QItemSelection::select ( const QModelIndex & topLeft, const QModelIndex & bottomRight )

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

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

Splits the selection range using the selection other range. Removes all items in other from range and puts the result in result. This can be compared with the semantics of the subtract operation of a set.

See also merge().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année

Le Qt Labs au hasard

Logo

QLocale : à propos du temps (et des dates, et des langues, et des...)

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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 4.2
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