Qt::Orientations QSpacerItemProto::expandingDirections() const { QSpacerItem *item = qscriptvalue_cast<QSpacerItem*>(thisObject()); if (item) return item->expandingDirections(); return (Qt::Orientations)0; }
/*! Sets the direction of this layout to \a direction. */ void QBoxLayout::setDirection(Direction direction) { Q_D(QBoxLayout); if (d->dir == direction) return; if (horz(d->dir) != horz(direction)) { //swap around the spacers (the "magic" bits) //#### a bit yucky, knows too much. //#### probably best to add access functions to spacerItem //#### or even a QSpacerItem::flip() for (int i = 0; i < d->list.size(); ++i) { QBoxLayoutItem *box = d->list.at(i); if (box->magic) { QSpacerItem *sp = box->item->spacerItem(); if (sp) { if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) { //spacing or strut QSize s = sp->sizeHint(); sp->changeSize(s.height(), s.width(), horz(direction) ? QSizePolicy::Fixed:QSizePolicy::Minimum, horz(direction) ? QSizePolicy::Minimum:QSizePolicy::Fixed); } else { //stretch if (horz(direction)) sp->changeSize(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); else sp->changeSize(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); } } } } } d->dir = direction; invalidate(); }