![]() |
| ||
Classes - Annotated - Tree - Functions - Home - Structure |
The QLayoutIterator class provides iterators over QLayoutItem. More...
#include <qabstractlayout.h>
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. QLayoutIterator itself is not designed to be subclassed.
This constructor is provided for layout implementors. Application programmers should use QLayoutItem::iterator() to create an iterator over a layout.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks | Qt version 3.0.0-beta2
|