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  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QLayoutIterator Class Reference


The QLayoutIterator class provides iterators over QLayoutItem. More...

#include <qabstractlayout.h>

List of all member functions.

Public Members


Detailed Description

The QLayoutIterator class provides iterators over QLayoutItem.

Use QLayoutItem::iterator() to create an iterator over a layout.

QLayoutIterator uses explicit sharing with a reference count. If an iterator is copied, and one of the copies is modified, both iterators will be modified.

A QLayoutIterator is not protected against changes in its layout. If the layout is modified or deleted, the iterator will become invalid. It is not possible to test for validity. It is safe to delete an invalid layout. Any other access may lead to an illegal memory reference, and the abnormal termination of the program.

Calling takeCurrent() or deleteCurrent() leaves the iterator in a valid state, but may invalidate any other iterators that access the same layout.

The following code will draw a rectangle for each layout item in the layout structure of the widget.

  static void paintLayout( QPainter *p, QLayoutItem *lay )
  {
      QLayoutIterator it = lay->iterator();
      QLayoutItem *child;
      while ( (child = it.current() ) ) {
          paintLayout( p, child );
          it.next();
      }
      p->drawRect( lay->geometry() );
  }
  void ExampleWidget::paintEvent( QPaintEvent * )
  {
      QPainter p( this );
      if ( layout() )
          paintLayout( &p, layout() );
  }

All the functionality of QLayoutIterator is implemented by subclasses of QGLayoutIterator. Note that there is not much point in subclassing QLayoutIterator, since none of the functions are virtual.


Member Function Documentation

QLayoutIterator::QLayoutIterator ( QGLayoutIterator * gi )

Constructs an iterator based on gi. The constructed iterator takes ownership of gi, and will delete it.

This constructor is provided for layout implementors. Application programmers should use QLayoutItem::iterator() to create an iterator over a layout.

QLayoutIterator::QLayoutIterator ( const QLayoutIterator & i )

Creates a shallow copy of i; if the copy is modified, then the original will also be modified.

QLayoutIterator::~QLayoutIterator ()

Destroys the iterator.

QLayoutItem * QLayoutIterator::current ()

Returns the current item, or 0 if there is no current item.

void QLayoutIterator::deleteCurrent ()

Removes and deletes the current child item from the layout and moves the iterator to the next item. This iterator will still be valid, but any other iterator over the same layout may become invalid.

QLayoutItem * QLayoutIterator::operator++ ()

Moves the iterator to the next child item, and returns that item, or 0 if there is no such item.

QLayoutIterator & QLayoutIterator::operator= ( const QLayoutIterator & i )

Assigns i to this iterator and returns a reference to this iterator.

QLayoutItem * QLayoutIterator::takeCurrent ()

Removes the current child item from the layout without deleting it and moves the iterator to the next item. Returns the removed item, or 0 if there was no item to be removed. This iterator will still be valid, but any other iterator over the same layout may become invalid.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

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 2.3
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