QLayoutIterator(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QLayoutIterator β€” the qlayoutiterator.3qt glow-up πŸ’–

okay bestie, buckle UP β€” this is the Qt 3 man page for QLayoutIterator(3qt), and we're gonna make it make sense. πŸ¦‹


✨ NAME ✨

QLayoutIterator β€” it's giving iterators over QLayoutItem. that's the whole job. that's the vibe. πŸ’…


✨ SYNOPSIS ✨

#include <qlayout.h>

🌸 Public Members 🌸

  • QLayoutIterator ( QGLayoutIterator * gi )
  • QLayoutIterator ( const QLayoutIterator & i )
  • ~QLayoutIterator ()
  • QLayoutIterator & operator= ( const QLayoutIterator & i )
  • QLayoutItem * operator++ ()
  • QLayoutItem * current ()
  • QLayoutItem * takeCurrent ()
  • void deleteCurrent ()

✨ DESCRIPTION ✨

so the QLayoutIterator class is literally just iterators over QLayoutItem. that's it. that's the plot. πŸ‘‘

want one? use QLayoutItem::iterator() to create an iterator over a layout. easy. ✨

QLayoutIterator uses explicit sharing with a reference count. and here's the tea β˜• β€” if you copy an iterator and then modify one of the copies, both iterators will be modified. they're linked like that. no cap. 😭

🚨 BIG WARNING ENERGY 🚨 β€” a QLayoutIterator is not protected against changes in its layout. if the layout gets modified or deleted, your iterator becomes invalid. and the worst part? 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. so like... be careful bestie. πŸ™ˆ

calling takeCurrent() or deleteCurrent() leaves the iterator in a valid state, but may invalidate any other iterators that access the same layout. sharing is caring until it isn't. 🫢

okay now the fun part β€” 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()) != 0 ) {
        paintLayout( p, child );
        ++it;
    }
    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. and listen β€” QLayoutIterator itself is not designed to be subclassed. don't try it. it said no. πŸ’…

See also Widget Appearance and Style and Layout Management. 🌈


✨ MEMBER FUNCTION DOCUMENTATION ✨

🌟 QLayoutIterator::QLayoutIterator ( QGLayoutIterator * gi )

constructs an iterator based on gi. and guess what β€” the constructed iterator takes ownership of gi and will delete it. so don't go deleting it yourself, that's not your business anymore. πŸ™ˆ

this constructor is provided for layout implementors. application programmers?? y'all should use QLayoutItem::iterator() to create an iterator over a layout. stay in your lane, respectfully. πŸ’–

🌟 QLayoutIterator::QLayoutIterator ( const QLayoutIterator & i )

creates a shallow copy of i, i.e. if the copy is modified, then the original will also be modified. they're matching. they're twins. it's giving ✨entanglement✨. πŸ”₯

🌟 QLayoutIterator::~QLayoutIterator ()

destroys the iterator. bye bestie πŸ‘‹πŸ’€

🌟 QLayoutItem * QLayoutIterator::current ()

returns the current item, or 0 if there is no current item. simple. clean. iconic. 🌸

🌟 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. you've been warned fr fr.

🌟 QLayoutItem * QLayoutIterator::operator++ ()

moves the iterator to the next child item and returns that item, or 0 if there is no such item. slay. πŸ‘‘

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

assigns i to this iterator and returns a reference to this iterator. standard assignment behavior, no drama. πŸ’…

🌟 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. it's yours now, bestie, take care of it 🫢. this iterator will still be valid, but any other iterator over the same layout may become invalid. same warning, same energy.


✨ SEE ALSO ✨


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. see the license file included in the distribution for a complete license statement. πŸ“œβœ¨


✨ AUTHOR ✨

Generated automatically from the source code. not a human, not a bot, just vibes (and a script). πŸ€–πŸ’œ


✨ BUGS ✨

found a bug in Qt? report it as described in http://doc.trolltech.com/bughowto.html. good bug reports help us to help you. thank you. 🫢 like genuinely, thank you, you're doing the lord's work. πŸ™

the definitive Qt documentation is provided in HTML format β€” it lives at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. 🌐 this man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. it's the side quest, not the main quest. πŸ’…

found errors in this manual page? report them to qt-bugs@trolltech.com. please include the name of the manual page (qlayoutiterator.3qt) and the Qt version (3.3.8). πŸ“


and that's the whole page, bestie!! πŸŽ€πŸ’–βœ¨ brought to you by Trolltech AS, dated 2 February 2007, filed forever under QLayoutIterator(3qt). mwah πŸ’‹ go forth and iterate responsibly πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from