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  ·  Fonctions  · 

QListViewItemIterator Class Reference

The QListViewItemIterator class provides an iterator for collections of QListViewItems. More...

#include <qlistview.h>

List of all member functions.

Public Members


Detailed Description

The QListViewItemIterator class provides an iterator for collections of QListViewItems.

Construct an instance of a QListViewItemIterator, with either a QListView* or a QListViewItem* as argument, to operate on the tree of QListViewItems, starting from the argument.

A QListViewItemIterator iterates over all the items from its starting point. This means that it always makes the first child of the current item the new current item. If there is no child, the next sibling becomes the new current item; and if there is no next sibling, the next sibling of the parent becomes current.

The following example creates a list of all the items that have been selected by the user, storing pointers to the items in a QPtrList:

    QPtrList<QListViewItem> lst;
    QListViewItemIterator it( myListView );
    while ( it.current() ) {
        if ( it.current()->isSelected() )
            lst.append( it.current() );
        ++it;
    }
    

An alternative approach is to use an IteratorFlag:

    QPtrList<QListViewItem> lst;
    QListViewItemIterator it( myListView, Selected );
    while ( it.current() ) {
        lst.append( it.current() );
        ++it;
    }
    

A QListViewItemIterator provides a convenient and easy way to traverse a hierarchical QListView.

Multiple QListViewItemIterators can operate on the tree of QListViewItems. A QListView knows about all iterators operating on its QListViewItems. So when a QListViewItem gets removed all iterators that point to this item are updated and point to the following item if possible, otherwise to a valid item before the current one or to 0. Note however that deleting the parent item of an item that an iterator points to is not safe.

See also QListView, QListViewItem, and Advanced Widgets.


Member Type Documentation

QListViewItemIterator::IteratorFlag

These flags can be passed to a QListViewItemIterator constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags.

  • QListViewItemIterator::Visible
  • QListViewItemIterator::Invisible
  • QListViewItemIterator::Selected
  • QListViewItemIterator::Unselected
  • QListViewItemIterator::Selectable
  • QListViewItemIterator::NotSelectable
  • QListViewItemIterator::DragEnabled
  • QListViewItemIterator::DragDisabled
  • QListViewItemIterator::DropEnabled
  • QListViewItemIterator::DropDisabled
  • QListViewItemIterator::Expandable
  • QListViewItemIterator::NotExpandable
  • QListViewItemIterator::Checked
  • QListViewItemIterator::NotChecked

Member Function Documentation

QListViewItemIterator::QListViewItemIterator ()

Constructs an empty iterator.

QListViewItemIterator::QListViewItemIterator ( QListViewItem * item )

Constructs an iterator for the QListView that contains the item. The current iterator item is set to point to the item.

QListViewItemIterator::QListViewItemIterator ( QListViewItem * item, int iteratorFlags )

Constructs an iterator for the QListView that contains the item using the flags iteratorFlags. The current iterator item is set to point to item or the next matching item if item doesn't match the flags.

See also QListViewItemIterator::IteratorFlag.

QListViewItemIterator::QListViewItemIterator ( const QListViewItemIterator & it )

Constructs an iterator for the same QListView as it. The current iterator item is set to point on the current item of it.

QListViewItemIterator::QListViewItemIterator ( QListView * lv )

Constructs an iterator for the QListView lv. The current iterator item is set to point on the first child (QListViewItem) of lv.

QListViewItemIterator::QListViewItemIterator ( QListView * lv, int iteratorFlags )

Constructs an iterator for the QListView lv with the flags iteratorFlags. The current iterator item is set to point on the first child (QListViewItem) of lv that matches the flags.

See also QListViewItemIterator::IteratorFlag.

QListViewItemIterator::~QListViewItemIterator ()

Destroys the iterator.

QListViewItem * QListViewItemIterator::current () const

Returns iterator's current item.

Examples: addressbook/centralwidget.cpp, checklists/checklists.cpp, and dirview/dirview.cpp.

QListViewItem * QListViewItemIterator::operator* ()

Dereference operator. Returns a reference to the current item. The same as current().

QListViewItemIterator & QListViewItemIterator::operator++ ()

Prefix ++. Makes the next item the new current item and returns it. Returns 0 if the current item is the last item or the QListView is 0.

const QListViewItemIterator QListViewItemIterator::operator++ ( int )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Postfix ++. Makes the next item the new current item and returns the item that was the current item.

QListViewItemIterator & QListViewItemIterator::operator+= ( int j )

Sets the current item to the item j positions after the current item. If that item is beyond the last item, the current item is set to 0. Returns the current item.

QListViewItemIterator & QListViewItemIterator::operator-- ()

Prefix --. Makes the previous item the new current item and returns it. Returns 0 if the current item is the first item or the QListView is 0.

const QListViewItemIterator QListViewItemIterator::operator-- ( int )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Postfix --. Makes the previous item the new current item and returns the item that was the current item.

QListViewItemIterator & QListViewItemIterator::operator-= ( int j )

Sets the current item to the item j positions before the current item. If that item is before the first item, the current item is set to 0. Returns the current item.

QListViewItemIterator & QListViewItemIterator::operator= ( const QListViewItemIterator & it )

Assignment. Makes a copy of it and returns a reference to its iterator.

This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

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 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenVG

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 3.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