#include <qlayout.h>
Inheritance diagram for QLayout:
This is an abstract base class inherited by the concrete classes QBoxLayout, QGridLayout, and QStackedLayout.
For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setSizeConstraint() or setMenuBar(). See {Layout Classes} for more information.
To make your own layout manager, implement the functions addItem(), sizeHint(), setGeometry(), itemAt() and takeAt(). You should also implement minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the {layouts/borderlayout}{Border Layout} and {layouts/flowlayout}{Flow Layout} examples for more information about implementing custom layout managers.
Geometry management stops when the layout manager is deleted.
Definition at line 69 of file qlayout.h.
Public Types | |
enum | SizeConstraint |
Public Member Functions | |
QLayout (QWidget *parent) | |
QLayout () | |
~QLayout () | |
int | margin () const |
int | spacing () const |
void | setMargin (int) |
void | setSpacing (int) |
bool | setAlignment (QWidget *w, Qt::Alignment alignment) |
bool | setAlignment (QLayout *l, Qt::Alignment alignment) |
void | setSizeConstraint (SizeConstraint) |
SizeConstraint | sizeConstraint () const |
void | setMenuBar (QWidget *w) |
QWidget * | menuBar () const |
QWidget * | parentWidget () const |
void | invalidate () |
QRect | geometry () const |
bool | activate () |
void | update () |
void | addWidget (QWidget *w) |
virtual void | addItem (QLayoutItem *)=0 |
void | removeWidget (QWidget *w) |
void | removeItem (QLayoutItem *) |
Qt::Orientations | expandingDirections () const |
QSize | minimumSize () const |
QSize | maximumSize () const |
void | setGeometry (const QRect &)=0 |
virtual QLayoutItem * | itemAt (int index) const=0 |
virtual QLayoutItem * | takeAt (int index)=0 |
virtual int | indexOf (QWidget *) const |
virtual int | count () const=0 |
bool | isEmpty () const |
int | totalHeightForWidth (int w) const |
QSize | totalMinimumSize () const |
QSize | totalMaximumSize () const |
QSize | totalSizeHint () const |
QLayout * | layout () |
void | setEnabled (bool) |
bool | isEnabled () const |
Static Public Member Functions | |
static QSize | closestAcceptableSize (const QWidget *w, const QSize &s) |
Protected Member Functions | |
void | widgetEvent (QEvent *) |
void | childEvent (QChildEvent *e) |
void | addChildLayout (QLayout *l) |
void | addChildWidget (QWidget *w) |
QRect | alignmentRect (const QRect &) const |
QLayout (QLayoutPrivate &d, QLayout *, QWidget *) | |
Static Private Member Functions | |
static void | activateRecursiveHelper (QLayoutItem *item) |
Friends | |
class | QApplicationPrivate |
class | QWidget |
The possible values are:
SetDefaultConstraint The main widget's minimum size is set to minimumSize(), unless the widget already has a minimum size.
SetFixedSize The main widget's size is set to sizeHint(); it cannot be resized at all. SetMinimumSize The main widget's minimum size is set to minimumSize(); it cannot be smaller.
SetMaximumSize The main widget's maximum size is set to maximumSize(); it cannot be larger.
SetMinAndMaxSize The main widget's minimum size is set to minimumSize() and its maximum size is set to maximumSize().
SetNoConstraint The widget is not constrained.
Auto FreeResize Minimum Fixed
Definition at line 80 of file qlayout.h.
00080 { 00081 SetDefaultConstraint, 00082 SetNoConstraint, 00083 SetMinimumSize, 00084 SetFixedSize, 00085 SetMaximumSize, 00086 SetMinAndMaxSize 00087 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) 00088 , Auto = SetDefaultConstraint, 00089 FreeResize = SetNoConstraint, 00090 Minimum = SetMinimumSize, 00091 Fixed = SetFixedSize 00092 #endif 00093 };
QLayout::QLayout | ( | QWidget * | parent | ) |
Constructs a new top-level QLayout, with parent parent. parent may not be 0.
There can be only one top-level layout for a widget. It is returned by QWidget::layout().
Definition at line 82 of file qlayout.cpp.
References QObject::parent().
00083 : QObject(*new QLayoutPrivate, parent) 00084 { 00085 if (!parent) 00086 return; 00087 parent->setLayout(this); 00088 }
Here is the call graph for this function:
QLayout::QLayout | ( | ) |
Constructs a new child QLayout.
This layout has to be inserted into another layout before geometry management will work.
Definition at line 96 of file qlayout.cpp.
00097 : QObject(*new QLayoutPrivate, 0) 00098 { 00099 }
QLayout::~QLayout | ( | ) |
Definition at line 678 of file qlayout.cpp.
References d, QObject::isWidgetType(), layout(), and QObject::parent().
00679 { 00680 Q_D(QLayout); 00681 /* 00682 This function may be called during the QObject destructor, 00683 when the parent no longer is a QWidget. 00684 */ 00685 if (d->topLevel && parent() && parent()->isWidgetType() && 00686 ((QWidget*)parent())->layout() == this) 00687 ((QWidget*)parent())->d_func()->layout = 0; 00688 }
Here is the call graph for this function:
QLayout::QLayout | ( | QLayoutPrivate & | d, | |
QLayout * | , | |||
QWidget * | ||||
) | [protected] |
Definition at line 104 of file qlayout.cpp.
References addItem(), d, invalidate(), QObject::objectName(), qWarning(), QObject::setParent(), and w.
00105 : QObject(dd, lay ? static_cast<QObject*>(lay) : static_cast<QObject*>(w)) 00106 { 00107 Q_D(QLayout); 00108 if (lay) { 00109 lay->addItem(this); 00110 } else if (w) { 00111 if (w->layout()) { 00112 qWarning("QLayout: Attempting to add QLayout \"%s\" to %s \"%s\", which" 00113 " already has a layout", 00114 qPrintable(QObject::objectName()), w->metaObject()->className(), 00115 w->objectName().toLocal8Bit().data()); 00116 setParent(0); 00117 } else { 00118 d->topLevel = true; 00119 w->d_func()->layout = this; 00120 invalidate(); 00121 } 00122 } 00123 }
Here is the call graph for this function:
int QLayout::margin | ( | ) | const |
Definition at line 317 of file qlayout.cpp.
References d, QWidget::isWindow(), parentWidget(), QStyle::pixelMetric(), QStyle::PM_DefaultChildMargin, QStyle::PM_DefaultTopLevelMargin, QWidget::style(), Qt::SubWindow, and QWidget::windowType().
Referenced by QBoxLayout::heightForWidth(), QGridLayout::heightForWidth(), QLayoutWidget::layoutMargin(), qdesigner_internal::Layout::margin(), QBoxLayout::maximumSize(), QGridLayout::maximumSize(), QGridLayout::minimumHeightForWidth(), QBoxLayout::minimumHeightForWidth(), QBoxLayout::minimumSize(), FlowLayout::minimumSize(), QGridLayout::minimumSize(), QFontDialog::QFontDialog(), QLayoutSupport::rebuildGridLayout(), QToolBar::resizeEvent(), QBoxLayout::setGeometry(), QGridLayout::setGeometry(), QGridLayout::sizeHint(), and QBoxLayout::sizeHint().
00318 { 00319 Q_D(const QLayout); 00320 if ( d->outsideBorder >= 0 ) 00321 return d->outsideBorder; 00322 if (!d->topLevel) 00323 return 0; 00324 QWidget *pw = parentWidget(); 00325 if (pw) 00326 return pw->style()->pixelMetric( 00327 (pw->isWindow() || (pw->windowType() == Qt::SubWindow)) 00328 ? QStyle::PM_DefaultTopLevelMargin 00329 : QStyle::PM_DefaultChildMargin 00330 ); 00331 return 0; 00332 }
Here is the call graph for this function:
int QLayout::spacing | ( | ) | const |
Definition at line 335 of file qlayout.cpp.
References d, QObject::parent(), parentWidget(), QStyle::pixelMetric(), QStyle::PM_DefaultLayoutSpacing, QApplication::style(), and QWidget::style().
Referenced by Dialog::buttonsOrientationChanged(), FlowLayout::doLayout(), QGridLayout::expandingDirections(), QGridLayout::hasHeightForWidth(), QGridLayout::heightForWidth(), QColorDialogPrivate::init(), QLayoutWidget::layoutSpacing(), QGridLayout::maximumSize(), QGridLayout::minimumHeightForWidth(), QGridLayout::minimumSize(), QColorShower::QColorShower(), QFontDialog::QFontDialog(), QLayoutSupport::rebuildGridLayout(), QToolBar::resizeEvent(), QBoxLayout::setGeometry(), BorderLayout::setGeometry(), QGridLayout::setGeometry(), QGridLayout::sizeHint(), and qdesigner_internal::Layout::spacing().
00336 { 00337 Q_D(const QLayout); 00338 if (d->insideSpacing >=0) { 00339 return d->insideSpacing; 00340 } else if (d->topLevel) { 00341 QWidget *pw = parentWidget(); 00342 if (pw) 00343 return pw->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); 00344 else 00345 return QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); 00346 } else if (parent()) { 00347 return static_cast<QLayout*>(parent())->spacing(); 00348 } else { 00349 return -1; //this is a layout that hasn't been inserted yet 00350 } 00351 }
Here is the call graph for this function:
void QLayout::setMargin | ( | int | ) |
Definition at line 361 of file qlayout.cpp.
References d, and invalidate().
Referenced by AnimationSaveWidget::AnimationSaveWidget(), BorderLayout::BorderLayout(), qdesigner_internal::BrushEditor::BrushEditor(), WidgetGallery::createBottomLeftTabWidget(), QCalendarWidgetPrivate::createHeader(), EditorWithReset::EditorWithReset(), qdesigner_internal::FindIconDialog::FindIconDialog(), FlowLayout::FlowLayout(), FormHolder::FormHolder(), Q3HBox::frameChanged(), Q3Grid::frameChanged(), GradientEditor::GradientEditor(), QWorkspaceChild::iconWidget(), QMessageBoxPrivate::init(), qdesigner_internal::FormWindow::init(), QDockWidgetPrivate::init(), Q3FileDialog::init(), QToolBarPrivate::init(), qdesigner_internal::GraphicsPropertyEditor::init(), Q3DockWindow::init(), QDialogButtonBoxPrivate::initLayout(), qdesigner_internal::ObjectInspector::ObjectInspector(), PathStrokeWidget::PathStrokeWidget(), qdesigner_internal::PreviewFrame::PreviewFrame(), PreviewFrame::PreviewFrame(), qdesigner_internal::PropertyEditor::PropertyEditor(), Q3DockAreaLayout::Q3DockAreaLayout(), QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(), QBalloonTip::QBalloonTip(), QCalendarPopup::QCalendarPopup(), QCalendarWidget::QCalendarWidget(), QColorShower::QColorShower(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QFDProgressDialog::QFDProgressDialog(), QMessageBoxDetailsText::QMessageBoxDetailsText(), QVFbRateDialog::QVFbRateDialog(), QView3D::QView3D(), QLayoutSupport::rebuildGridLayout(), QDockWidgetPrivate::relayout(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), qdesigner_internal::RoleEditor::RoleEditor(), QLayoutWidget::setLayoutMargin(), QFileDialogPrivate::setupToolButtons(), qdesigner_internal::SignalSlotEditorWindow::SignalSlotEditorWindow(), TransEditor::TransEditor(), TrWindow::TrWindow(), and Q3DockWindow::updateGui().
00362 { 00363 Q_D(QLayout); 00364 d->outsideBorder = margin; 00365 invalidate(); 00366 }
Here is the call graph for this function:
void QLayout::setSpacing | ( | int | ) |
Definition at line 369 of file qlayout.cpp.
References d, and invalidate().
Referenced by AnimationSaveWidget::AnimationSaveWidget(), BorderLayout::BorderLayout(), QCalendarWidgetPrivate::createHeader(), EditorWithReset::EditorWithReset(), FlowLayout::FlowLayout(), GradientEditor::GradientEditor(), QMessageBoxPrivate::init(), QDockWidgetPrivate::init(), QToolBarPrivate::init(), qdesigner_internal::GraphicsPropertyEditor::init(), Q3DockWindow::init(), QDialogButtonBoxPrivate::initLayout(), MessageEditor::MessageEditor(), Q3DockAreaLayout::Q3DockAreaLayout(), QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(), QBalloonTip::QBalloonTip(), QCalendarPopup::QCalendarPopup(), QCalendarWidget::QCalendarWidget(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QFDProgressDialog::QFDProgressDialog(), QFontDialog::QFontDialog(), QLayoutSupport::rebuildGridLayout(), qdesigner_internal::RoleEditor::RoleEditor(), QLayoutWidget::setLayoutSpacing(), Q3HBox::setSpacing(), Q3Grid::setSpacing(), QFileDialogPrivate::setupToolButtons(), and TransEditor::TransEditor().
00370 { 00371 Q_D(QLayout); 00372 d->insideSpacing = spacing; 00373 invalidate(); 00374 }
Here is the call graph for this function:
bool QLayout::setAlignment | ( | QWidget * | w, | |
Qt::Alignment | alignment | |||
) |
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false.
Definition at line 250 of file qlayout.cpp.
References i, invalidate(), itemAt(), QLayoutItem::setAlignment(), w, and QLayoutItem::widget().
Referenced by alignmentRect(), QToolBarPrivate::init(), Q3GroupBox::setColumnLayout(), and QToolBar::setOrientation().
00251 { 00252 int i = 0; 00253 QLayoutItem *item = itemAt(i); 00254 while (item) { 00255 if (item->widget() == w) { 00256 item->setAlignment(alignment); 00257 invalidate(); 00258 return true; 00259 } 00260 ++i; 00261 item = itemAt(i); 00262 } 00263 return false; 00264 }
Here is the call graph for this function:
bool QLayout::setAlignment | ( | QLayout * | l, | |
Qt::Alignment | alignment | |||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false.
Definition at line 273 of file qlayout.cpp.
References i, invalidate(), itemAt(), l, QLayoutItem::layout(), and QLayoutItem::setAlignment().
00274 { 00275 int i = 0; 00276 QLayoutItem *item = itemAt(i); 00277 while (item) { 00278 if (item->layout() == l) { 00279 item->setAlignment(alignment); 00280 invalidate(); 00281 return true; 00282 } 00283 ++i; 00284 item = itemAt(i); 00285 } 00286 return false; 00287 }
Here is the call graph for this function:
void QLayout::setSizeConstraint | ( | SizeConstraint | ) |
Definition at line 1164 of file qlayout.cpp.
References d, and invalidate().
Referenced by Dialog::buttonsOrientationChanged(), ImageComposer::ImageComposer(), QMessageBoxPrivate::init(), QBalloonTip::QBalloonTip(), and QFileDialogPrivate::setupToolButtons().
01165 { 01166 Q_D(QLayout); 01167 if (constraint == d->constraint) 01168 return; 01169 01170 d->constraint = constraint; 01171 invalidate(); 01172 }
Here is the call graph for this function:
QLayout::SizeConstraint QLayout::sizeConstraint | ( | ) | const |
void QLayout::setMenuBar | ( | QWidget * | widget | ) |
Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar.
Definition at line 851 of file qlayout.cpp.
References addChildWidget(), d, and QLayoutItem::widget().
Referenced by Dialog::Dialog().
00852 { 00853 Q_D(QLayout); 00854 if (widget) 00855 addChildWidget(widget); 00856 d->menubar = widget; 00857 }
Here is the call graph for this function:
QWidget * QLayout::menuBar | ( | ) | const |
Returns the menu bar set for this layout, or 0 if no menu bar is set.
Definition at line 864 of file qlayout.cpp.
References d.
Referenced by QMainWindow::menuWidget().
QWidget * QLayout::parentWidget | ( | ) | const |
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget.
If the layout is a sub-layout, this function returns the parent widget of the parent layout.
Definition at line 385 of file qlayout.cpp.
References d, QObject::isWidgetType(), QObject::parent(), and parentWidget().
Referenced by addChildLayout(), addChildWidget(), alignmentRect(), QMainWindowLayout::allAnimationsFinished(), QMainWindowLayout::getTabBar(), Q3DockAreaLayout::heightForWidth(), QMainWindowLayout::hover(), Q3DockAreaLayout::layoutItems(), QMainWindowLayout::locateToolBar(), margin(), parentWidget(), QMainWindowLayout::plug(), QMainWindowLayout::restoreState(), QStackedLayout::setCurrentIndex(), QBoxLayout::setGeometry(), QMainWindowLayout::setGeometry(), spacing(), totalHeightForWidth(), totalMaximumSize(), totalMinimumSize(), and totalSizeHint().
00386 { 00387 Q_D(const QLayout); 00388 if (!d->topLevel) { 00389 if (parent()) { 00390 QLayout *parentLayout = ::qobject_cast<QLayout*>(parent()); 00391 Q_ASSERT(parentLayout); 00392 return parentLayout->parentWidget(); 00393 } else { 00394 return 0; 00395 } 00396 } else { 00397 Q_ASSERT(parent() && parent()->isWidgetType()); 00398 return static_cast<QWidget *>(parent()); 00399 } 00400 }
Here is the call graph for this function:
void QLayout::invalidate | ( | ) | [virtual] |
Reimplemented from QLayoutItem.
Definition at line 439 of file qlayout.cpp.
Referenced by childEvent(), QStackedLayout::insertWidget(), QBoxLayout::invalidate(), QGridLayout::invalidate(), QMainWindowLayout::invalidate(), QLayout(), qdesigner_internal::InsertWidgetCommand::redo(), removeItem(), removeWidget(), removeWidgetRecursively(), setAlignment(), setMargin(), setSizeConstraint(), setSpacing(), QWidget::updateGeometry(), Q3DockArea::updateLayout(), and widgetEvent().
Here is the call graph for this function:
QRect QLayout::geometry | ( | ) | const [virtual] |
Implements QLayoutItem.
Definition at line 430 of file qlayout.cpp.
References d.
Referenced by QLayoutSupport::extendedGeometry(), Q3DockAreaLayout::invalidate(), Q3MainWindowLayout::layoutItems(), Q3DockAreaLayout::minimumSize(), Q3TextTable::pageBreak(), QMainWindowLayout::relayout(), Q3TextTable::resize(), QBoxLayout::setGeometry(), QGridLayout::setGeometry(), and Q3DockAreaLayout::sizeHint().
bool QLayout::activate | ( | ) |
Redoes the layout for parentWidget() if necessary.
You should generally not need to call this because it is automatically called at the most appropriate times.
Definition at line 964 of file qlayout.cpp.
References activateRecursiveHelper(), d, data, QWExtra::explicitMinSize, QWidgetPrivate::extra, QLayoutItem::hasHeightForWidth(), QSize::height(), Qt::Horizontal, QWidget::isWindow(), QLayoutItem::minimumHeightForWidth(), QWidget::minimumSize(), QObject::objectName(), QObject::parent(), qWarning(), SetDefaultConstraint, QWidget::setFixedSize(), SetFixedSize, QSize::setHeight(), SetMaximumSize, QWidget::setMaximumSize(), SetMinAndMaxSize, SetMinimumSize, QWidget::setMinimumSize(), SetNoConstraint, QSize::setWidth(), QWidget::size(), totalMaximumSize(), totalMinimumSize(), totalSizeHint(), QWidget::updateGeometry(), Qt::Vertical, and QSize::width().
Referenced by qdesigner_internal::ChangeLayoutItemGeometry::changeItemPosition(), Q3ToolBar::event(), QLayoutSupport::insertColumn(), QLayoutSupport::insertRow(), Q3Wizard::layOut(), Q3DockArea::lineUp(), qdesigner_internal::WidgetHandle::mouseReleaseEvent(), Q3TabDialog::setUpLayout(), QWidgetPrivate::show_recursive(), Q3FileDialog::updateGeometries(), Q3DockArea::updateLayout(), and widgetEvent().
00965 { 00966 Q_D(QLayout); 00967 if (!d->enabled || !parent()) 00968 return false; 00969 if (!d->topLevel) 00970 return static_cast<QLayout*>(parent())->activate(); 00971 if (d->activated) 00972 return false; 00973 QWidget *mw = static_cast<QWidget*>(parent()); 00974 if (mw == 0) { 00975 qWarning("QLayout::activate: %s \"%s\" does not have a main widget", 00976 QObject::metaObject()->className(), QObject::objectName().toLocal8Bit().data()); 00977 return false; 00978 } 00979 activateRecursiveHelper(this); 00980 00981 QWidgetPrivate *md = mw->d_func(); 00982 uint explMin = md->extra ? md->extra->explicitMinSize : 0; 00983 00984 switch (d->constraint) { 00985 case SetFixedSize: 00986 // will trigger resize 00987 mw->setFixedSize(totalSizeHint()); 00988 break; 00989 case SetMinimumSize: 00990 mw->setMinimumSize(totalMinimumSize()); 00991 break; 00992 case SetMaximumSize: 00993 mw->setMaximumSize(totalMaximumSize()); 00994 break; 00995 case SetMinAndMaxSize: 00996 mw->setMinimumSize(totalMinimumSize()); 00997 mw->setMaximumSize(totalMaximumSize()); 00998 break; 00999 case SetDefaultConstraint: { 01000 bool widthSet = explMin & Qt::Horizontal; 01001 bool heightSet = explMin & Qt::Vertical; 01002 if (mw->isWindow()) { 01003 QSize ms = totalMinimumSize(); 01004 if (widthSet) 01005 ms.setWidth(mw->minimumSize().width()); 01006 if (heightSet) 01007 ms.setHeight(mw->minimumSize().height()); 01008 if ((!heightSet || !widthSet) && hasHeightForWidth()) { 01009 int h = minimumHeightForWidth(ms.width()); 01010 if (h > ms.height()) { 01011 if (!heightSet) 01012 ms.setHeight(0); 01013 if (!widthSet) 01014 ms.setWidth(0); 01015 } 01016 } 01017 mw->setMinimumSize(ms); 01018 } else if (!widthSet || !heightSet) { 01019 QSize ms = mw->minimumSize(); 01020 if (!widthSet) 01021 ms.setWidth(0); 01022 if (!heightSet) 01023 ms.setHeight(0); 01024 mw->setMinimumSize(ms); 01025 } 01026 break; 01027 } 01028 case SetNoConstraint: 01029 break; 01030 } 01031 01032 d->doResize(mw->size()); 01033 01034 if (md->extra) 01035 md->extra->explicitMinSize = explMin; 01036 // ideally only if sizeHint() or sizePolicy() has changed 01037 mw->updateGeometry(); 01038 return true; 01039 }
Here is the call graph for this function:
void QLayout::update | ( | ) |
Updates the layout for parentWidget().
You should generally not need to call this because it is automatically called at the most appropriate times.
Definition at line 940 of file qlayout.cpp.
References QWidget::isVisible(), QObject::isWidgetType(), layout(), QEvent::LayoutRequest, QObject::parent(), and QCoreApplication::postEvent().
Referenced by invalidate(), QMainWindowLayout::relayout(), QX11EmbedWidget::resizeEvent(), and QWidget::setVisible().
00941 { 00942 QLayout *layout = this; 00943 while (layout && layout->d_func()->activated) { 00944 layout->d_func()->activated = false; 00945 if (layout->d_func()->topLevel) { 00946 Q_ASSERT(layout->parent()->isWidgetType()); 00947 QWidget *mw = static_cast<QWidget*>(layout->parent()); 00948 if (mw->isVisible()) 00949 QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest)); 00950 break; 00951 } 00952 layout = static_cast<QLayout*>(layout->parent()); 00953 } 00954 }
Here is the call graph for this function:
void QLayout::addWidget | ( | QWidget * | w | ) |
Adds widget w to this layout in a manner specific to the layout. This function uses addItem().
Definition at line 237 of file qlayout.cpp.
References addChildWidget(), addItem(), and w.
Referenced by qdesigner_internal::FormWindowWidgetStack::addTool(), QGridLayout::addWidget(), ApplicationsTab::ApplicationsTab(), qdesigner_internal::BrushEditor::BrushEditor(), CalculatorForm::CalculatorForm(), ConnectionWidget::ConnectionWidget(), WidgetGallery::createBottomRightGroupBox(), Dialog::createGridGroupBox(), ControllerWindow::createHintsGroupBox(), Dialog::createHorizontalGroupBox(), MainWindow::createIconSizeGroupBox(), MainWindow::createImagesGroupBox(), MainWindow::createPreviewGroupBox(), WidgetGallery::createTopLeftGroupBox(), WidgetGallery::createTopRightGroupBox(), ControllerWindow::createTypeGroupBox(), Dialog::Dialog(), qdesigner_internal::FindIconDialog::FindIconDialog(), qdesigner_internal::FormWindow::init(), QToolBarPrivate::init(), qdesigner_internal::GraphicsPropertyEditor::init(), LCDRange::init(), ItemDialog::ItemDialog(), Q3Wizard::layOutTitleRow(), LCDRange::LCDRange(), FormHolder::loadFormFile(), MainWindow::MainWindow(), MultiPageWidget::MultiPageWidget(), PreviewWindow::PreviewWindow(), QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(), QBalloonTip::QBalloonTip(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QDBusViewer::QDBusViewer(), QFDProgressDialog::QFDProgressDialog(), QMessageBoxDetailsText::QMessageBoxDetailsText(), QPageSetupDialog::QPageSetupDialog(), QView3D::QView3D(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), qdesigner_internal::RoleEditor::RoleEditor(), qdesigner_internal::QDesignerPromotedWidget::setChildWidget(), qdesigner_internal::SignalSlotEditorWindow::SignalSlotEditorWindow(), qdesigner_internal::StyleSheetEditorDialog::StyleSheetEditorDialog(), TetrixWindow::TetrixWindow(), VersionDialog::VersionDialog(), and Zoomer::Zoomer().
00238 { 00239 addChildWidget(w); 00240 addItem(new QWidgetItem(w)); 00241 }
Here is the call graph for this function:
void QLayout::addItem | ( | QLayoutItem * | item | ) | [pure virtual] |
Implemented in subclasses to add an item. How it is added is specific to each subclass.
The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
Referenced by addWidget(), QLayout(), QPageSetupDialog::QPageSetupDialog(), and widgetEvent().
void QLayout::removeWidget | ( | QWidget * | widget | ) |
Removes the widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.
Definition at line 1241 of file qlayout.cpp.
References i, invalidate(), itemAt(), takeAt(), and QLayoutItem::widget().
Referenced by QToolBoxPrivate::_q_widgetDestroyed(), QToolBar::actionEvent(), Dialog::buttonsOrientationChanged(), QLayoutSupport::removeWidget(), QAbstractScrollAreaPrivate::replaceScrollBar(), Dialog::rotateWidgets(), qdesigner_internal::QDesignerPromotedWidget::setChildWidget(), QMessageBox::setInformativeText(), and Q3DockWindow::setOrientation().
01242 { 01243 int i = 0; 01244 QLayoutItem *child; 01245 while ((child = itemAt(i))) { 01246 if (child->widget() == widget) { 01247 delete takeAt(i); 01248 invalidate(); 01249 } else { 01250 ++i; 01251 } 01252 } 01253 }
Here is the call graph for this function:
void QLayout::removeItem | ( | QLayoutItem * | item | ) |
Removes the layout item item from the layout. It is the caller's responsibility to delete the item.
Notice that item can be a layout (since QLayout inherits QLayoutItem).
Definition at line 1264 of file qlayout.cpp.
References i, invalidate(), itemAt(), and takeAt().
01265 { 01266 int i = 0; 01267 QLayoutItem *child; 01268 while ((child = itemAt(i))) { 01269 if (child == item) { 01270 takeAt(i); 01271 invalidate(); 01272 } else { 01273 ++i; 01274 } 01275 } 01276 }
Here is the call graph for this function:
Qt::Orientations QLayout::expandingDirections | ( | ) | const [virtual] |
Returns whether this layout can make use of more space than sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, whereas Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions.
The default implementation returns Qt::Horizontal | Qt::Vertical. Subclasses reimplement it to return a meaningful value based on their child widgets's {QSizePolicy}{size policies}.
Implements QLayoutItem.
Definition at line 913 of file qlayout.cpp.
References Qt::Horizontal, and Qt::Vertical.
Referenced by alignmentRect(), and QWidgetItem::expandingDirections().
00914 { 00915 return Qt::Horizontal | Qt::Vertical; 00916 }
QSize QLayout::minimumSize | ( | ) | const [virtual] |
Returns the minimum size of this layout. This is the smallest size that the layout can have while still respecting the specifications.
The returned value doesn't include the space required by QWidget::setContentsMargins() or menuBar().
The default implementation allows unlimited resizing.
Implements QLayoutItem.
Definition at line 881 of file qlayout.cpp.
Referenced by totalMinimumSize().
00882 { 00883 return QSize(0, 0); 00884 }
QSize QLayout::maximumSize | ( | ) | const [virtual] |
Returns the maximum size of this layout. This is the largest size that the layout can have while still respecting the specifications.
The returned value doesn't include the space required by QWidget::setContentsMargins() or menuBar().
The default implementation allows unlimited resizing.
Implements QLayoutItem.
Definition at line 896 of file qlayout.cpp.
References QLAYOUTSIZE_MAX.
Referenced by alignmentRect(), and totalMaximumSize().
00897 { 00898 return QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX); 00899 }
void QLayout::setGeometry | ( | const QRect & | r | ) | [pure virtual] |
Implements QLayoutItem.
Definition at line 421 of file qlayout.cpp.
References d.
Referenced by Q3DockAreaLayout::setGeometry(), Q3MainWindowLayout::setGeometry(), QBoxLayout::setGeometry(), BorderLayout::setGeometry(), QMainWindowLayout::setGeometry(), QGridLayout::setGeometry(), and FlowLayout::setGeometry().
QLayoutItem * QLayout::itemAt | ( | int | index | ) | const [pure virtual] |
Must be implemented in subclasses to return the layout item at index. If there is no such item, the function must return 0. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered.
This function can be used to iterate over a layout. The following code will draw a rectangle for each layout item in the layout structure of the widget.
static void paintLayout(QPainter *painter, QLayoutItem *item) { QLayout *layout = item->layout(); if (layout) { for (int i = 0; i < layout->count(); ++i) paintLayout(painter, layout->itemAt(i)); } painter->drawRect(lay->geometry()); } void MyWidget::paintEvent(QPaintEvent *) { QPainter painter(this); if (layout()) paintLayout(&painter, layout()); }
Referenced by activateRecursiveHelper(), QLayoutSupport::adjustIndicator(), childEvent(), QLayoutSupport::extendedGeometry(), findWidgetRecursively(), indexOf(), isEmpty(), QToolBarHandle::mousePressEvent(), removeItem(), removeWidget(), removeWidgetRecursively(), QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex(), setAlignment(), QToolBar::setIconSize(), QAbstractScrollAreaScrollBarContainer::widgets(), and QLayoutSupport::widgets().
QLayoutItem * QLayout::takeAt | ( | int | index | ) | [pure virtual] |
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. If there is no such item, the function must do nothing and return 0. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered.
The following code fragment shows a safe way to remove all items from a layout:
QLayoutItem *child; while ((child = layout->takeAt(0)) != 0) { ... delete child; }
Referenced by childEvent(), QLayoutSupport::removeColumn(), removeItem(), QLayoutSupport::removeRow(), removeWidget(), and removeWidgetRecursively().
int QLayout::indexOf | ( | QWidget * | widget | ) | const [virtual] |
Searches for widget widget in this layout (not including child layouts).
Returns the index of widget, or -1 if widget is not found.
The default implementation iterates over all items using itemAt()
Definition at line 1113 of file qlayout.cpp.
References i, itemAt(), and QLayoutItem::widget().
Referenced by qdesigner_internal::ChangeLayoutItemGeometry::changeItemPosition(), qdesigner_internal::ChangeLayoutItemGeometry::init(), qdesigner_internal::LayoutInfo::isWidgetLaidout(), and QStackedLayout::setCurrentWidget().
01114 { 01115 int i = 0; 01116 QLayoutItem *item = itemAt(i); 01117 while (item) { 01118 if (item->widget() == widget) 01119 return i; 01120 ++i; 01121 item = itemAt(i); 01122 } 01123 return -1; 01124 }
Here is the call graph for this function:
int * QLayout::count | ( | ) | const [pure virtual] |
Must be implemented in subclasses to return the number of items in the layout.
Referenced by QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex(), and QAbstractScrollAreaScrollBarContainer::widgets().
bool QLayout::isEmpty | ( | ) | const [virtual] |
Implements QLayoutItem.
Definition at line 405 of file qlayout.cpp.
References i, QLayoutItem::isEmpty(), and itemAt().
00406 { 00407 int i = 0; 00408 QLayoutItem *item = itemAt(i); 00409 while (item) { 00410 if (!item->isEmpty()) 00411 return false; 00412 ++i; 00413 item = itemAt(i); 00414 } 00415 return true; 00416 }
Here is the call graph for this function:
int QLayout::totalHeightForWidth | ( | int | w | ) | const |
Definition at line 577 of file qlayout.cpp.
References QWidgetPrivate::bottommargin, d, h, QLayoutItem::heightForWidth(), QWidgetPrivate::leftmargin, menuBarHeightForWidth(), QObject::parent(), parentWidget(), QWidgetPrivate::rightmargin, and QWidgetPrivate::topmargin.
Referenced by QWidget::heightForWidth(), and QWidgetItem::heightForWidth().
00578 { 00579 Q_D(const QLayout); 00580 int side=0, top=0; 00581 if (d->topLevel) { 00582 QWidget *parent = parentWidget(); 00583 parent->ensurePolished(); 00584 QWidgetPrivate *wd = parent->d_func(); 00585 side += wd->leftmargin + wd->rightmargin; 00586 top += wd->topmargin + wd->bottommargin; 00587 } 00588 int h = heightForWidth(w - side) + top; 00589 #ifndef QT_NO_MENUBAR 00590 h += menuBarHeightForWidth(d->menubar, w); 00591 #endif 00592 return h; 00593 }
Here is the call graph for this function:
QSize QLayout::totalMinimumSize | ( | ) | const |
Definition at line 599 of file qlayout.cpp.
References QWidgetPrivate::bottommargin, d, QWidget::ensurePolished(), QWidgetPrivate::leftmargin, menuBarHeightForWidth(), minimumSize(), parentWidget(), QWidgetPrivate::rightmargin, s, and QWidgetPrivate::topmargin.
Referenced by activate().
00600 { 00601 Q_D(const QLayout); 00602 int side=0, top=0; 00603 if (d->topLevel) { 00604 QWidget *pw = parentWidget(); 00605 pw->ensurePolished(); 00606 QWidgetPrivate *wd = pw->d_func(); 00607 side += wd->leftmargin + wd->rightmargin; 00608 top += wd->topmargin + wd->bottommargin; 00609 } 00610 00611 QSize s = minimumSize(); 00612 #ifndef QT_NO_MENUBAR 00613 top += menuBarHeightForWidth(d->menubar, s.width() + side); 00614 #endif 00615 return s + QSize(side, top); 00616 }
Here is the call graph for this function:
QSize QLayout::totalMaximumSize | ( | ) | const |
Definition at line 647 of file qlayout.cpp.
References QWidgetPrivate::bottommargin, d, QWidget::ensurePolished(), QWidgetPrivate::leftmargin, maximumSize(), menuBarHeightForWidth(), parentWidget(), QLAYOUTSIZE_MAX, qMin(), QWidgetPrivate::rightmargin, s, and QWidgetPrivate::topmargin.
Referenced by activate().
00648 { 00649 Q_D(const QLayout); 00650 int side=0, top=0; 00651 if (d->topLevel) { 00652 QWidget *pw = parentWidget(); 00653 pw->ensurePolished(); 00654 QWidgetPrivate *wd = pw->d_func(); 00655 side += wd->leftmargin + wd->rightmargin; 00656 top += wd->topmargin + wd->bottommargin; 00657 } 00658 00659 QSize s = maximumSize(); 00660 #ifndef QT_NO_MENUBAR 00661 top += menuBarHeightForWidth(d->menubar, s.width()); 00662 #endif 00663 00664 if (d->topLevel) 00665 s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX), 00666 qMin(s.height() + top, QLAYOUTSIZE_MAX)); 00667 return s; 00668 }
Here is the call graph for this function:
QSize QLayout::totalSizeHint | ( | ) | const |
Definition at line 622 of file qlayout.cpp.
References QWidgetPrivate::bottommargin, d, QWidget::ensurePolished(), QLayoutItem::hasHeightForWidth(), QLayoutItem::heightForWidth(), QWidgetPrivate::leftmargin, menuBarHeightForWidth(), parentWidget(), QWidgetPrivate::rightmargin, s, QLayoutItem::sizeHint(), and QWidgetPrivate::topmargin.
Referenced by activate().
00623 { 00624 Q_D(const QLayout); 00625 int side=0, top=0; 00626 if (d->topLevel) { 00627 QWidget *pw = parentWidget(); 00628 pw->ensurePolished(); 00629 QWidgetPrivate *wd = pw->d_func(); 00630 side += wd->leftmargin + wd->rightmargin; 00631 top += wd->topmargin + wd->bottommargin; 00632 } 00633 00634 QSize s = sizeHint(); 00635 if (hasHeightForWidth()) 00636 s.setHeight(heightForWidth(s.width() + side)); 00637 #ifndef QT_NO_MENUBAR 00638 top += menuBarHeightForWidth(d->menubar, s.width()); 00639 #endif 00640 return s + QSize(side, top); 00641 }
Here is the call graph for this function:
QLayout * QLayout::layout | ( | ) | [virtual] |
Reimplemented from QLayoutItem.
Definition at line 278 of file qlayoutitem.cpp.
Referenced by activateRecursiveHelper(), QGridLayout::addLayout(), QBoxLayout::addLayout(), QBoxLayout::insertLayout(), QWidget::layout(), QToolBar::setIconSize(), QBoxLayout::setStretchFactor(), update(), and ~QLayout().
void QLayout::setEnabled | ( | bool | enable | ) |
Enables this layout if enable is true, otherwise disables it.
An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.
By default all layouts are enabled.
Definition at line 1288 of file qlayout.cpp.
References d.
Referenced by QDialog::showExtension().
bool QLayout::isEnabled | ( | ) | const |
Returns true if the layout is enabled; otherwise returns false.
Definition at line 1299 of file qlayout.cpp.
References d.
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is as close as possible to size.
Definition at line 1311 of file qlayout.cpp.
References QSize::expandedTo(), QWidget::height(), QSize::height(), l, QWidget::layout(), qMax(), qMin(), qSmartMaxSize(), qSmartMinSize(), QSize::setHeight(), size, QWidget::size(), QLayoutItem::widget(), QSize::width(), and QWidget::width().
01312 { 01313 QSize result = size.boundedTo(qSmartMaxSize(widget)); 01314 result = result.expandedTo(qSmartMinSize(widget)); 01315 QLayout *l = widget->layout(); 01316 if (l && l->hasHeightForWidth() && result.height() < l->minimumHeightForWidth(result.width()) ) { 01317 QSize current = widget->size(); 01318 int currentHfw = l->minimumHeightForWidth(current.width()); 01319 int newHfw = l->minimumHeightForWidth(result.width()); 01320 if (current.height() < currentHfw || currentHfw == newHfw) { 01321 //handle the constant hfw case and the vertical-only case, as well as the 01322 // current-size-is-not-correct case 01323 result.setHeight(newHfw); 01324 } else { 01325 // binary search; assume hfw is decreasing ### 01326 01327 int maxw = qMax(widget->width(),result.width()); 01328 int maxh = qMax(widget->height(), result.height()); 01329 int minw = qMin(widget->width(),result.width()); 01330 int minh = qMin(widget->height(), result.height()); 01331 01332 int minhfw = l->minimumHeightForWidth(minw); 01333 int maxhfw = l->minimumHeightForWidth(maxw); 01334 while (minw < maxw) { 01335 if (minhfw > maxh) { //assume decreasing 01336 minw = maxw - (maxw-minw)/2; 01337 minhfw = l->minimumHeightForWidth(minw); 01338 } else if (maxhfw < minh ) { //assume decreasing 01339 maxw = minw + (maxw-minw)/2; 01340 maxhfw = l->minimumHeightForWidth(maxw); 01341 } else { 01342 break; 01343 } 01344 } 01345 result = result.expandedTo(QSize(minw, minhfw)); 01346 } 01347 } 01348 return result; 01349 }
Here is the call graph for this function:
void QLayout::widgetEvent | ( | QEvent * | ) | [protected] |
Definition at line 489 of file qlayout.cpp.
References activate(), addItem(), c, QEvent::ChildRemoved, d, invalidate(), QEvent::LayoutRequest, removeWidgetRecursively(), QEvent::Resize, QResizeEvent::size(), QEvent::type(), and w.
00490 { 00491 Q_D(QLayout); 00492 if (!d->enabled) 00493 return; 00494 00495 switch (e->type()) { 00496 case QEvent::Resize: 00497 if (d->activated) { 00498 QResizeEvent *r = (QResizeEvent *)e; 00499 d->doResize(r->size()); 00500 } else { 00501 activate(); 00502 } 00503 break; 00504 case QEvent::ChildRemoved: 00505 { 00506 QChildEvent *c = (QChildEvent *)e; 00507 if (c->child()->isWidgetType()) { 00508 QWidget *w = (QWidget *)c->child(); 00509 #ifndef QT_NO_MENUBAR 00510 if (w == d->menubar) 00511 d->menubar = 0; 00512 #endif 00513 removeWidgetRecursively(this, w); 00514 } 00515 } 00516 break; 00517 #ifdef QT3_SUPPORT 00518 case QEvent::ChildInserted: 00519 if (d->topLevel && d->autoNewChild) { 00520 QChildEvent *c = (QChildEvent *)e; 00521 if (c->child()->isWidgetType()) { 00522 QWidget *w = (QWidget *)c->child(); 00523 if (!w->isWindow()) { 00524 #if !defined(QT_NO_MENUBAR) && !defined(QT_NO_TOOLBAR) 00525 if (qobject_cast<QMenuBar*>(w) && !::qobject_cast<QToolBar*>(w->parentWidget())) { 00526 d->menubar = (QMenuBar *)w; 00527 invalidate(); 00528 } else 00529 #endif 00530 addItem(new QWidgetItem(w)); 00531 } 00532 } 00533 } 00534 break; 00535 case QEvent::LayoutHint: 00536 d->activated = false; 00537 // fall through 00538 #endif 00539 case QEvent::LayoutRequest: 00540 activate(); 00541 break; 00542 default: 00543 break; 00544 } 00545 }
Here is the call graph for this function:
void QLayout::childEvent | ( | QChildEvent * | e | ) | [protected, virtual] |
Reimplemented from QObject.
Definition at line 550 of file qlayout.cpp.
References c, QEvent::ChildRemoved, d, i, invalidate(), itemAt(), takeAt(), and QEvent::type().
00551 { 00552 Q_D(QLayout); 00553 if (!d->enabled) 00554 return; 00555 00556 if (e->type() == QEvent::ChildRemoved) { 00557 QChildEvent *c = (QChildEvent*)e; 00558 int i = 0; 00559 00560 QLayoutItem *item; 00561 while ((item = itemAt(i))) { 00562 if (item == static_cast<QLayout*>(c->child())) { 00563 takeAt(i); 00564 invalidate(); 00565 break; 00566 } else { 00567 ++i; 00568 } 00569 } 00570 } 00571 }
Here is the call graph for this function:
void QLayout::addChildLayout | ( | QLayout * | l | ) | [protected] |
This function is called from addLayout()
functions in subclasses to add layout l as a sub-layout.
Definition at line 706 of file qlayout.cpp.
References l, parentWidget(), and qWarning().
Referenced by QGridLayout::addLayout(), and QBoxLayout::insertLayout().
00707 { 00708 if (l->parent()) { 00709 qWarning("QLayout::addChildLayout: layout \"%s\" already has a parent", 00710 l->objectName().toLocal8Bit().data()); 00711 return; 00712 } 00713 l->setParent(this); 00714 00715 if (QWidget *mw = parentWidget()) { 00716 l->d_func()->reparentChildWidgets(mw); 00717 } 00718 00719 }
Here is the call graph for this function:
void QLayout::addChildWidget | ( | QWidget * | w | ) | [protected] |
This function is called from addWidget()
functions in subclasses to add w as a child widget.
If w is already in a layout, this function will give a warning and remove w from the layout. This function must therefore be called before adding w to the layout's data structure.
Definition at line 768 of file qlayout.cpp.
References QMetaObject::invokeMethod(), QWidget::isVisible(), l, QWidget::layout(), parentWidget(), Qt::QueuedConnection, qWarning(), removeWidgetRecursively(), w, Qt::WA_LaidOut, and Qt::WA_WState_ExplicitShowHide.
Referenced by QMainWindowLayout::addDockWidget(), QMainWindowLayout::addToolBar(), addWidget(), QGridLayout::addWidget(), QMainWindowLayout::insertToolBar(), QStackedLayout::insertWidget(), QBoxLayout::insertWidget(), QMainWindowLayout::setCentralWidget(), setMenuBar(), QMainWindowLayout::setStatusBar(), QMainWindowLayout::splitDockWidget(), and QMainWindowLayout::tabifyDockWidget().
00769 { 00770 QWidget *mw = parentWidget(); 00771 QWidget *pw = w->parentWidget(); 00772 00773 //Qt::WA_LaidOut is never reset. It only means that the widget at some point has 00774 //been in a layout. 00775 if (pw && w->testAttribute(Qt::WA_LaidOut)) { 00776 QLayout *l = pw->layout(); 00777 if (l && removeWidgetRecursively(l, w)) { 00778 #ifdef QT_DEBUG 00779 if (layoutDebug()) 00780 qWarning("QLayout::addChildWidget: %s \"%s\" is already in a layout; moved to new layout", 00781 w->metaObject()->className(), w->objectName().toLocal8Bit().data()); 00782 #endif 00783 } 00784 } 00785 if (pw && mw && pw != mw) { 00786 #ifdef QT_DEBUG 00787 if (layoutDebug()) 00788 qWarning("QLayout::addChildWidget: %s \"%s\" in wrong parent; moved to correct parent", 00789 w->metaObject()->className(), w->objectName().toLocal8Bit().data()); 00790 #endif 00791 pw = 0; 00792 } 00793 bool needShow = mw && mw->isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)); 00794 if (!pw && mw) 00795 w->setParent(mw); 00796 w->setAttribute(Qt::WA_LaidOut); 00797 if (needShow) 00798 QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later 00799 }
Here is the call graph for this function:
Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment().
The result is derived from sizeHint() and expanding(). It is never larger than r.
Definition at line 1188 of file qlayout.cpp.
References a, Qt::AlignBottom, Qt::AlignHorizontal_Mask, Qt::AlignLeft, QLayoutItem::alignment(), Qt::AlignRight, Qt::AlignTop, Qt::AlignVertical_Mask, expandingDirections(), QLayoutItem::hasHeightForWidth(), QRect::height(), QSize::height(), QLayoutItem::heightForWidth(), Qt::Horizontal, QApplication::layoutDirection(), maximumSize(), QObject::parent(), parentWidget(), qMin(), s, setAlignment(), QLayoutItem::sizeHint(), Qt::Vertical, QStyle::visualAlignment(), QRect::width(), QSize::width(), QRect::x(), x, QRect::y(), and y.
Referenced by QBoxLayout::setGeometry(), and QGridLayout::setGeometry().
01189 { 01190 QSize s = sizeHint(); 01191 Qt::Alignment a = alignment(); 01192 01193 /* 01194 This is a hack to obtain the real maximum size, not 01195 QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX), the value consistently 01196 returned by QLayoutItems that have an alignment. 01197 */ 01198 QLayout *that = const_cast<QLayout *>(this); 01199 that->setAlignment(0); 01200 QSize ms = that->maximumSize(); 01201 that->setAlignment(a); 01202 01203 if ((expandingDirections() & Qt::Horizontal) || 01204 !(a & Qt::AlignHorizontal_Mask)) { 01205 s.setWidth(qMin(r.width(), ms.width())); 01206 } 01207 if ((expandingDirections() & Qt::Vertical) || 01208 !(a & Qt::AlignVertical_Mask)) { 01209 s.setHeight(qMin(r.height(), ms.height())); 01210 } else if (hasHeightForWidth()) { 01211 int hfw = heightForWidth(s.width()); 01212 if (hfw < s.height()) 01213 s.setHeight(qMin(hfw, ms.height())); 01214 } 01215 01216 int x = r.x(); 01217 int y = r.y(); 01218 01219 if (a & Qt::AlignBottom) 01220 y += (r.height() - s.height()); 01221 else if (!(a & Qt::AlignTop)) 01222 y += (r.height() - s.height()) / 2; 01223 01224 QWidget *parent = parentWidget(); 01225 a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a); 01226 if (a & Qt::AlignRight) 01227 x += (r.width() - s.width()); 01228 else if (!(a & Qt::AlignLeft)) 01229 x += (r.width() - s.width()) / 2; 01230 01231 return QRect(x, y, s.width(), s.height()); 01232 }
Here is the call graph for this function:
void QLayout::activateRecursiveHelper | ( | QLayoutItem * | item | ) | [static, private] |
Definition at line 918 of file qlayout.cpp.
References i, QLayoutItem::invalidate(), itemAt(), layout(), and QLayoutItem::layout().
Referenced by activate().
00919 { 00920 item->invalidate(); 00921 QLayout *layout = item->layout(); 00922 if (layout) { 00923 QLayoutItem *child; 00924 int i=0; 00925 while ((child = layout->itemAt(i++))) 00926 activateRecursiveHelper(child); 00927 layout->d_func()->activated = true; 00928 } 00929 }
Here is the call graph for this function:
friend class QApplicationPrivate [friend] |