/*! Removes and deletes all items in this layout. */ void QLayout::deleteAllItems() { QLayoutIterator it = iterator(); QLayoutItem *l; while ( (l=it.takeCurrent()) ) delete l; }
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 ); }
void KstBasicDialogI::init() { KstBasicPluginPtr ptr; if (_newDialog) { ptr = kst_cast<KstBasicPlugin>(KstDataObject::plugin(_pluginName)); } else { ptr = kst_cast<KstBasicPlugin>(findObject(_pluginName)); } Q_ASSERT(ptr); //shouldn't happen if (_grid) { //reset QLayoutIterator it = _grid->iterator(); while(QLayoutItem *item = it.takeCurrent()) { delete item->widget(); delete item; } delete _grid; _grid = 0; } int cnt = 0; int numInputOutputs = ptr->inputVectorList().count() + ptr->inputScalarList().count() + ptr->inputStringList().count() + ptr->outputVectorList().count() + ptr->outputScalarList().count() + ptr->outputStringList().count(); _grid = new QGridLayout(_w->_frame, numInputOutputs + 1, 2, 0, 8); _grid->setColStretch(1,1); _grid->setColStretch(0,0); //create input widgets //First, the inputVectors... QStringList iv = ptr->inputVectorList(); QStringList::ConstIterator ivI = iv.begin(); for (; ivI != iv.end(); ++ivI) { createInputVector(*ivI, ++cnt); } //Now, the inputScalars... QStringList is = ptr->inputScalarList(); QStringList::ConstIterator isI = is.begin(); for (; isI != is.end(); ++isI) { createInputScalar(*isI, ++cnt); } //Finally, the inputStrings... QStringList istr = ptr->inputStringList(); QStringList::ConstIterator istrI = istr.begin(); for (; istrI != istr.end(); ++istrI) { createInputString(*istrI, ++cnt); } //create sep cnt++; QFrame* line = new QFrame(_w->_frame); line->setFrameShadow(QFrame::Sunken); line->setFrameShape(QFrame::HLine); _grid->addMultiCellWidget(line, cnt, cnt, 0, 1); line->show(); cnt++; //create output widgets //output vectors... QStringList ov = ptr->outputVectorList(); QStringList::ConstIterator ovI = ov.begin(); for (; ovI != ov.end(); ++ovI) { createOutputWidget(*ovI, ++cnt); } //output scalars... QStringList os = ptr->outputScalarList(); QStringList::ConstIterator osI = os.begin(); for (; osI != os.end(); ++osI) { createOutputWidget(*osI, ++cnt); } //ouput strings... QStringList ostr = ptr->outputStringList(); QStringList::ConstIterator ostrI = ostr.begin(); for (; ostrI != ostr.end(); ++ostrI) { createOutputWidget(*ostrI, ++cnt); } }