本文整理汇总了C++中QLayoutIterator::takeCurrent方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayoutIterator::takeCurrent方法的具体用法?C++ QLayoutIterator::takeCurrent怎么用?C++ QLayoutIterator::takeCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayoutIterator
的用法示例。
在下文中一共展示了QLayoutIterator::takeCurrent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteAllItems
/*!
Removes and deletes all items in this layout.
*/
void QLayout::deleteAllItems()
{
QLayoutIterator it = iterator();
QLayoutItem *l;
while ( (l=it.takeCurrent()) )
delete l;
}
示例2: eventFilter
bool QLayout::eventFilter( QObject *o, QEvent *e )
{
if ( !enabled )
return FALSE; // nothing we can do, should do or want to do
if ( o == this && e->type() == QEvent::ChildRemoved ) {
//we cannot implement childEvent() or event() because of
//###binary compatibility.
QChildEvent *c = (QChildEvent*)e;
QLayoutIterator it = iterator();
QLayoutItem *item;
while ( (item = it.current() ) ) {
if ( item == (QLayout*)c->child() ) {
it.takeCurrent();
invalidate();
return FALSE;
}
++it;
}
return FALSE;
}
if ( !o->isWidgetType() )
return FALSE;
switch ( e->type() ) {
case QEvent::Resize:
if ( activated ) {
QResizeEvent *r = (QResizeEvent*)e;
int mbh = 0;
#ifndef QT_NO_MENUBAR
if ( menubar && !menubar->isHidden() && !menubar->isTopLevel() )
mbh = menubar->heightForWidth( r->size().width() );
#endif
int b = marginImpl ? 0 : outsideBorder;
setGeometry( QRect( b, mbh + b, r->size().width() - 2*b,
r->size().height() - mbh - 2*b ) );
} else {
activate();
}
break;
case QEvent::ChildRemoved: {
QChildEvent *c = (QChildEvent*)e;
if ( c->child()->isWidgetType() ) {
QWidget *w = (QWidget*)c->child();
#ifndef QT_NO_MENUBAR
if ( w == menubar )
menubar = 0;
#endif
if ( removeWidget( this, w ) ) {
QEvent *lh = new QEvent( QEvent::LayoutHint );
QApplication::postEvent( o, lh );
}
}
break;
}
case QEvent::ChildInserted:
if ( topLevel && autoNewChild ) {
QChildEvent *c = (QChildEvent*)e;
if ( c->child()->isWidgetType() ) {
QWidget *w = (QWidget*)c->child();
if ( !w->isTopLevel() ) {
#ifndef QT_NO_MENUBAR
if ( w->inherits( "QMenuBar" ) && ( !w->parent() || !w->parent()->inherits( "QToolBar" ) ) )
menubar = (QMenuBar*)w;
else
#endif
addItem( new QWidgetItem( w ) );
QEvent *lh = new QEvent( QEvent::LayoutHint );
QApplication::postEvent( o, lh );
}
}
}
break;
case QEvent::LayoutHint:
activate();
break;
default:
break;
}
return QObject::eventFilter( o, e );
}