Qt 4.8
qlayout.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qlayout.h"
43 
44 #include "qapplication.h"
45 #include "qlayoutengine_p.h"
46 #include "qmenubar.h"
47 #include "qtoolbar.h"
48 #include "qsizegrip.h"
49 #include "qevent.h"
50 #include "qstyle.h"
51 #include "qvariant.h"
52 #include "qwidget_p.h"
53 #include "qlayout_p.h"
54 #include "qformlayout.h"
55 
57 
58 static int menuBarHeightForWidth(QWidget *menubar, int w)
59 {
60  if (menubar && !menubar->isHidden() && !menubar->isWindow()) {
61  int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth()));
62  if (result == -1)
63  result = menubar->sizeHint().height();
64  const int min = qSmartMinSize(menubar).height();
65  result = qBound(min, result, menubar->maximumSize().height());
66  if (result != -1)
67  return result;
68  }
69  return 0;
70 }
71 
114  : QObject(*new QLayoutPrivate, parent)
115 {
116  if (!parent)
117  return;
118  parent->setLayout(this);
119 }
120 
128  : QObject(*new QLayoutPrivate, 0)
129 {
130 }
131 
132 
136  : QObject(dd, lay ? static_cast<QObject*>(lay) : static_cast<QObject*>(w))
137 {
138  Q_D(QLayout);
139  if (lay) {
140  lay->addItem(this);
141  } else if (w) {
142  if (w->layout()) {
143  qWarning("QLayout: Attempting to add QLayout \"%s\" to %s \"%s\", which"
144  " already has a layout",
146  w->objectName().toLocal8Bit().data());
147  setParent(0);
148  } else {
149  d->topLevel = true;
150  w->d_func()->layout = this;
151  QT_TRY {
152  invalidate();
153  } QT_CATCH(...) {
154  w->d_func()->layout = 0;
155  QT_RETHROW;
156  }
157  }
158  }
159 }
160 
162  : QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1),
163  userBottomMargin(-1), topLevel(false), enabled(true), activated(true), autoNewChild(false),
164  constraint(QLayout::SetDefaultConstraint), menubar(0)
165 {
166 }
167 
168 void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const
169 {
170  if (!result)
171  return;
172 
173  Q_Q(const QLayout);
174  if (userMargin >= 0) {
175  *result = userMargin;
176  } else if (!topLevel) {
177  *result = 0;
178  } else if (QWidget *pw = q->parentWidget()) {
179  *result = pw->style()->pixelMetric(pm, 0, pw);
180  } else {
181  *result = 0;
182  }
183 }
184 
185 // Static item factory functions that allow for hooking things in Designer
186 
189 
191 {
193  if (QWidgetItem *wi = (*widgetItemFactoryMethod)(layout, widget))
194  return wi;
195  return new QWidgetItemV2(widget);
196 }
197 
199 {
201  if (QSpacerItem *si = (*spacerItemFactoryMethod)(layout, w, h, hPolicy, vPolicy))
202  return si;
203  return new QSpacerItem(w, h, hPolicy, vPolicy);
204 }
205 
206 #ifdef QT3_SUPPORT
207 
222 QLayout::QLayout(QWidget *parent, int margin, int spacing, const char *name)
223  : QObject(*new QLayoutPrivate,parent)
224 {
225  Q_D(QLayout);
226  setObjectName(QString::fromAscii(name));
227  setMargin(margin);
228  if (spacing < 0)
229  d->insideSpacing = margin;
230  else
231  d->insideSpacing = spacing;
232  if (parent) {
233  if (parent->layout()) {
234  qWarning("QLayout \"%s\" added to %s \"%s\", which already has a layout",
235  QObject::objectName().toLocal8Bit().data(), parent->metaObject()->className(),
236  parent->objectName().toLocal8Bit().data());
237  parent->layout()->setParent(0);
238  } else {
239  d->topLevel = true;
240  parent->d_func()->layout = this;
241  QT_TRY {
242  invalidate();
243  } QT_CATCH(...) {
244  parent->d_func()->layout = 0;
245  QT_RETHROW;
246  }
247  }
248  }
249 }
250 
259 QLayout::QLayout(QLayout *parentLayout, int spacing, const char *name)
260  : QObject(*new QLayoutPrivate,parentLayout)
261 
262 {
263  Q_D(QLayout);
264  setObjectName(QString::fromAscii(name));
265  d->insideSpacing = spacing;
266  parentLayout->addItem(this);
267 }
268 
277 QLayout::QLayout(int spacing, const char *name)
278  : QObject(*new QLayoutPrivate, 0)
279 {
280  Q_D(QLayout);
281  setObjectName(QString::fromAscii(name));
282  d->insideSpacing = spacing;
283 }
284 
289 void QLayout::setAutoAdd(bool a) { Q_D(QLayout); d->autoNewChild = a; }
290 
295 bool QLayout::autoAdd() const { Q_D(const QLayout); return d->autoNewChild; }
296 #endif
297 
298 
320 {
321  addChildWidget(w);
322  addItem(QLayoutPrivate::createWidgetItem(this, w));
323 }
324 
325 
326 
332 bool QLayout::setAlignment(QWidget *w, Qt::Alignment alignment)
333 {
334  int i = 0;
335  QLayoutItem *item = itemAt(i);
336  while (item) {
337  if (item->widget() == w) {
338  item->setAlignment(alignment);
339  invalidate();
340  return true;
341  }
342  ++i;
343  item = itemAt(i);
344  }
345  return false;
346 }
347 
358 bool QLayout::setAlignment(QLayout *l, Qt::Alignment alignment)
359 {
360  int i = 0;
361  QLayoutItem *item = itemAt(i);
362  while (item) {
363  if (item->layout() == l) {
364  item->setAlignment(alignment);
365  invalidate();
366  return true;
367  }
368  ++i;
369  item = itemAt(i);
370  }
371  return false;
372 }
373 
411 int QLayout::margin() const
412 {
413  int left, top, right, bottom;
414  getContentsMargins(&left, &top, &right, &bottom);
415  if (left == top && top == right && right == bottom) {
416  return left;
417  } else {
418  return -1;
419  }
420 }
421 
442 int QLayout::spacing() const
443 {
444  if (const QBoxLayout* boxlayout = qobject_cast<const QBoxLayout*>(this)) {
445  return boxlayout->spacing();
446  } else if (const QGridLayout* gridlayout = qobject_cast<const QGridLayout*>(this)) {
447  return gridlayout->spacing();
448  } else if (const QFormLayout* formlayout = qobject_cast<const QFormLayout*>(this)) {
449  return formlayout->spacing();
450  } else {
451  Q_D(const QLayout);
452  if (d->insideSpacing >=0) {
453  return d->insideSpacing;
454  } else {
455  // arbitrarily prefer horizontal spacing to vertical spacing
457  }
458  }
459 }
460 
464 void QLayout::setMargin(int margin)
465 {
466  setContentsMargins(margin, margin, margin, margin);
467 }
468 
469 void QLayout::setSpacing(int spacing)
470 {
471  if (QBoxLayout* boxlayout = qobject_cast<QBoxLayout*>(this)) {
472  boxlayout->setSpacing(spacing);
473  } else if (QGridLayout* gridlayout = qobject_cast<QGridLayout*>(this)) {
474  gridlayout->setSpacing(spacing);
475  } else if (QFormLayout* formlayout = qobject_cast<QFormLayout*>(this)) {
476  formlayout->setSpacing(spacing);
477  } else {
478  Q_D(QLayout);
479  d->insideSpacing = spacing;
480  invalidate();
481  }
482 }
483 
502 void QLayout::setContentsMargins(int left, int top, int right, int bottom)
503 {
504  Q_D(QLayout);
505 
506  if (d->userLeftMargin == left && d->userTopMargin == top &&
507  d->userRightMargin == right && d->userBottomMargin == bottom)
508  return;
509 
510  d->userLeftMargin = left;
511  d->userTopMargin = top;
512  d->userRightMargin = right;
513  d->userBottomMargin = bottom;
514  invalidate();
515 }
516 
531 {
532  setContentsMargins(margins.left(), margins.top(), margins.right(), margins.bottom());
533 }
534 
551 void QLayout::getContentsMargins(int *left, int *top, int *right, int *bottom) const
552 {
553  Q_D(const QLayout);
554  d->getMargin(left, d->userLeftMargin, QStyle::PM_LayoutLeftMargin);
555  d->getMargin(top, d->userTopMargin, QStyle::PM_LayoutTopMargin);
556  d->getMargin(right, d->userRightMargin, QStyle::PM_LayoutRightMargin);
557  d->getMargin(bottom, d->userBottomMargin, QStyle::PM_LayoutBottomMargin);
558 }
559 
574 {
575  int left, top, right, bottom;
576  getContentsMargins(&left, &top, &right, &bottom);
577  return QMargins(left, top, right, bottom);
578 }
579 
592 {
593  Q_D(const QLayout);
594  int left, top, right, bottom;
595  getContentsMargins(&left, &top, &right, &bottom);
596  return d->rect.adjusted(+left, +top, -right, -bottom);
597 }
598 
599 #ifdef QT3_SUPPORT
600 bool QLayout::isTopLevel() const
601 {
602  Q_D(const QLayout);
603  return d->topLevel;
604 }
605 #endif
606 
617 {
618  Q_D(const QLayout);
619  if (!d->topLevel) {
620  if (parent()) {
621  QLayout *parentLayout = qobject_cast<QLayout*>(parent());
622  if (!parentLayout) {
623  qWarning("QLayout::parentWidget: A layout can only have another layout as a parent.");
624  return 0;
625  }
626  return parentLayout->parentWidget();
627  } else {
628  return 0;
629  }
630  } else {
631  Q_ASSERT(parent() && parent()->isWidgetType());
632  return static_cast<QWidget *>(parent());
633  }
634 }
635 
639 bool QLayout::isEmpty() const
640 {
641  int i = 0;
642  QLayoutItem *item = itemAt(i);
643  while (item) {
644  if (!item->isEmpty())
645  return false;
646  ++i;
647  item = itemAt(i);
648  }
649  return true;
650 }
651 
656 {
657  Q_D(QLayout);
658  d->rect = r;
659 }
660 
665 {
666  Q_D(const QLayout);
667  return d->rect;
668 }
669 
674 {
675  Q_D(QLayout);
676  d->rect = QRect();
677  update();
678 }
679 
681 {
682  QLayout *lay = li->layout();
683  if (!lay)
684  return false;
685  int i = 0;
686  QLayoutItem *child;
687  while ((child = lay->itemAt(i))) {
688  if (child->widget() == w) {
689  delete lay->takeAt(i);
690  lay->invalidate();
691  return true;
692  } else if (removeWidgetRecursively(child, w)) {
693  return true;
694  } else {
695  ++i;
696  }
697  }
698  return false;
699 }
700 
701 
703 {
704  Q_Q(QLayout);
705  int mbh = menuBarHeightForWidth(menubar, r.width());
706  QWidget *mw = q->parentWidget();
707  QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
708  rect.setTop(rect.top() + mbh);
709  q->setGeometry(rect);
710 #ifndef QT_NO_MENUBAR
711  if (menubar)
712  menubar->setGeometry(0,0,r.width(), mbh);
713 #endif
714 }
715 
716 
727 {
728  Q_D(QLayout);
729  if (!d->enabled)
730  return;
731 
732  switch (e->type()) {
733  case QEvent::Resize:
734  if (d->activated) {
735  QResizeEvent *r = (QResizeEvent *)e;
736  d->doResize(r->size());
737  } else {
738  activate();
739  }
740  break;
742  {
743  QChildEvent *c = (QChildEvent *)e;
744  if (c->child()->isWidgetType()) {
745  QWidget *w = (QWidget *)c->child();
746 #ifndef QT_NO_MENUBAR
747  if (w == d->menubar)
748  d->menubar = 0;
749 #endif
750  removeWidgetRecursively(this, w);
751  }
752  }
753  break;
754 #ifdef QT3_SUPPORT
755  case QEvent::ChildInserted:
756  if (d->topLevel && d->autoNewChild) {
757  QChildEvent *c = (QChildEvent *)e;
758  if (c->child()->isWidgetType()) {
759  QWidget *w = (QWidget *)c->child();
760  if (!w->isWindow()) {
761 #if !defined(QT_NO_MENUBAR) && !defined(QT_NO_TOOLBAR)
762  if (qobject_cast<QMenuBar*>(w) && !qobject_cast<QToolBar*>(w->parentWidget())) {
763  d->menubar = (QMenuBar *)w;
764  invalidate();
765  } else
766 #endif
767 #ifndef QT_NO_SIZEGRIP
768  if (qobject_cast<QSizeGrip*>(w) ) {
769  //SizeGrip is handled by the dialog itself.
770  } else
771 #endif
772  addItem(QLayoutPrivate::createWidgetItem(this, w));
773  }
774  }
775  }
776  break;
777  case QEvent::LayoutHint:
778  d->activated = false;
779  // fall through
780 #endif
782  if (static_cast<QWidget *>(parent())->isVisible())
783  activate();
784  break;
785  default:
786  break;
787  }
788 }
789 
794 {
795  Q_D(QLayout);
796  if (!d->enabled)
797  return;
798 
799  if (e->type() == QEvent::ChildRemoved) {
800  QChildEvent *c = (QChildEvent*)e;
801  int i = 0;
802 
803  QLayoutItem *item;
804  while ((item = itemAt(i))) {
805  if (item == static_cast<QLayout*>(c->child())) {
806  takeAt(i);
807  invalidate();
808  break;
809  } else {
810  ++i;
811  }
812  }
813  }
814 }
815 
824 {
825  Q_D(const QLayout);
826  int side=0, top=0;
827  if (d->topLevel) {
828  QWidget *parent = parentWidget();
829  parent->ensurePolished();
830  QWidgetPrivate *wd = parent->d_func();
831  side += wd->leftmargin + wd->rightmargin;
832  top += wd->topmargin + wd->bottommargin;
833  }
834  int h = heightForWidth(w - side) + top;
835 #ifndef QT_NO_MENUBAR
836  h += menuBarHeightForWidth(d->menubar, w);
837 #endif
838  return h;
839 }
840 
849 {
850  Q_D(const QLayout);
851  int side=0, top=0;
852  if (d->topLevel) {
853  QWidget *pw = parentWidget();
854  pw->ensurePolished();
855  QWidgetPrivate *wd = pw->d_func();
856  side += wd->leftmargin + wd->rightmargin;
857  top += wd->topmargin + wd->bottommargin;
858  }
859 
860  QSize s = minimumSize();
861 #ifndef QT_NO_MENUBAR
862  top += menuBarHeightForWidth(d->menubar, s.width() + side);
863 #endif
864  return s + QSize(side, top);
865 }
866 
875 {
876  Q_D(const QLayout);
877  int side=0, top=0;
878  if (d->topLevel) {
879  QWidget *pw = parentWidget();
880  pw->ensurePolished();
881  QWidgetPrivate *wd = pw->d_func();
882  side += wd->leftmargin + wd->rightmargin;
883  top += wd->topmargin + wd->bottommargin;
884  }
885 
886  QSize s = sizeHint();
887  if (hasHeightForWidth())
888  s.setHeight(heightForWidth(s.width() + side));
889 #ifndef QT_NO_MENUBAR
890  top += menuBarHeightForWidth(d->menubar, s.width());
891 #endif
892  return s + QSize(side, top);
893 }
894 
903 {
904  Q_D(const QLayout);
905  int side=0, top=0;
906  if (d->topLevel) {
907  QWidget *pw = parentWidget();
908  pw->ensurePolished();
909  QWidgetPrivate *wd = pw->d_func();
910  side += wd->leftmargin + wd->rightmargin;
911  top += wd->topmargin + wd->bottommargin;
912  }
913 
914  QSize s = maximumSize();
915 #ifndef QT_NO_MENUBAR
916  top += menuBarHeightForWidth(d->menubar, s.width());
917 #endif
918 
919  if (d->topLevel)
920  s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX),
921  qMin(s.height() + top, QLAYOUTSIZE_MAX));
922  return s;
923 }
924 
937 {
938  Q_D(QLayout);
939  /*
940  This function may be called during the QObject destructor,
941  when the parent no longer is a QWidget.
942  */
943  if (d->topLevel && parent() && parent()->isWidgetType() &&
944  ((QWidget*)parent())->layout() == this)
945  ((QWidget*)parent())->d_func()->layout = 0;
946 }
947 
948 #ifdef QT3_SUPPORT
949 
952 void QLayout::deleteAllItems()
953 {
954  QLayoutItem *l;
955  while ((l = takeAt(0)))
956  delete l;
957 }
958 #endif
959 
970 {
971  if (l->parent()) {
972  qWarning("QLayout::addChildLayout: layout \"%s\" already has a parent",
973  l->objectName().toLocal8Bit().data());
974  return;
975  }
976  l->setParent(this);
977 
978  if (QWidget *mw = parentWidget()) {
979  l->d_func()->reparentChildWidgets(mw);
980  }
981 
982 }
983 
988 {
989  const bool ok = !layout->parent();
990  addChildLayout(layout);
991  return ok;
992 }
993 
994 #ifdef QT_DEBUG
995 static bool layoutDebug()
996 {
997  static int checked_env = -1;
998  if(checked_env == -1)
999  checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
1000 
1001  return checked_env;
1002 }
1003 #endif
1004 
1006 {
1007  Q_Q(QLayout);
1008  int n = q->count();
1009 
1010 #ifndef QT_NO_MENUBAR
1011  if (menubar && menubar->parentWidget() != mw) {
1012  menubar->setParent(mw);
1013  }
1014 #endif
1015  bool mwVisible = mw && mw->isVisible();
1016  for (int i = 0; i < n; ++i) {
1017  QLayoutItem *item = q->itemAt(i);
1018  if (QWidget *w = item->widget()) {
1019  QWidget *pw = w->parentWidget();
1020 #ifdef QT_DEBUG
1021  if (pw && pw != mw && layoutDebug()) {
1022  qWarning("QLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent",
1023  w->metaObject()->className(), w->objectName().toLocal8Bit().data());
1024  }
1025 #endif
1026  bool needShow = mwVisible && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide));
1027  if (pw != mw)
1028  w->setParent(mw);
1029  if (needShow)
1030  QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later
1031  } else if (QLayout *l = item->layout()) {
1032  l->d_func()->reparentChildWidgets(mw);
1033  }
1034  }
1035 }
1036 
1046 {
1047  QWidget *mw = parentWidget();
1048  QWidget *pw = w->parentWidget();
1049 
1050  //Qt::WA_LaidOut is never reset. It only means that the widget at some point has
1051  //been in a layout.
1052  if (pw && w->testAttribute(Qt::WA_LaidOut)) {
1053  QLayout *l = pw->layout();
1054  if (l && removeWidgetRecursively(l, w)) {
1055 #ifdef QT_DEBUG
1056  if (layoutDebug())
1057  qWarning("QLayout::addChildWidget: %s \"%s\" is already in a layout; moved to new layout",
1058  w->metaObject()->className(), w->objectName().toLocal8Bit().data());
1059 #endif
1060  }
1061  }
1062  if (pw && mw && pw != mw) {
1063 #ifdef QT_DEBUG
1064  if (layoutDebug())
1065  qWarning("QLayout::addChildWidget: %s \"%s\" in wrong parent; moved to correct parent",
1066  w->metaObject()->className(), w->objectName().toLocal8Bit().data());
1067 #endif
1068  pw = 0;
1069  }
1070  bool needShow = mw && mw->isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide));
1071  if (!pw && mw)
1072  w->setParent(mw);
1074  if (needShow)
1075  QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later
1076 }
1077 
1078 #ifdef QT3_SUPPORT
1079 
1102 void QLayout::freeze(int w, int h)
1103 {
1104  Q_D(QLayout);
1105  if (!d->topLevel)
1106  return;
1107  if (w <= 0 || h <= 0) {
1108  QSize s = totalSizeHint();
1109  w = s.width();
1110  h = s.height();
1111  }
1112  setSizeConstraint(SetNoConstraint); // layout will not change min/max size
1113  QWidget *parent = parentWidget();
1114  if (parent)
1115  parent->setFixedSize(w, h);
1116 }
1117 
1118 #endif
1119 
1120 
1121 
1122 
1123 
1124 
1125 
1132 {
1133  Q_D(QLayout);
1134 
1135 #ifdef Q_OS_WINCE_WM
1136  if (widget && widget->size().height() > 0)
1137 #else
1138  if (widget)
1139 #endif
1140  addChildWidget(widget);
1141  d->menubar = widget;
1142 }
1143 
1150 {
1151  Q_D(const QLayout);
1152  return d->menubar;
1153 }
1154 
1155 
1167 {
1168  return QSize(0, 0);
1169 }
1170 
1182 {
1184 }
1185 
1198 Qt::Orientations QLayout::expandingDirections() const
1199 {
1200  return Qt::Horizontal | Qt::Vertical;
1201 }
1202 
1204 {
1205  item->invalidate();
1206  QLayout *layout = item->layout();
1207  if (layout) {
1208  QLayoutItem *child;
1209  int i=0;
1210  while ((child = layout->itemAt(i++)))
1211  activateRecursiveHelper(child);
1212  layout->d_func()->activated = true;
1213  }
1214 }
1215 
1226 {
1227  QLayout *layout = this;
1228  while (layout && layout->d_func()->activated) {
1229  layout->d_func()->activated = false;
1230  if (layout->d_func()->topLevel) {
1231  Q_ASSERT(layout->parent()->isWidgetType());
1232  QWidget *mw = static_cast<QWidget*>(layout->parent());
1234  break;
1235  }
1236  layout = static_cast<QLayout*>(layout->parent());
1237  }
1238 }
1239 
1250 {
1251  Q_D(QLayout);
1252  if (!d->enabled || !parent())
1253  return false;
1254  if (!d->topLevel)
1255  return static_cast<QLayout*>(parent())->activate();
1256  if (d->activated)
1257  return false;
1258  QWidget *mw = static_cast<QWidget*>(parent());
1259  if (mw == 0) {
1260  qWarning("QLayout::activate: %s \"%s\" does not have a main widget",
1261  QObject::metaObject()->className(), QObject::objectName().toLocal8Bit().data());
1262  return false;
1263  }
1264  activateRecursiveHelper(this);
1265 
1266  QWidgetPrivate *md = mw->d_func();
1267  uint explMin = md->extra ? md->extra->explicitMinSize : 0;
1268  uint explMax = md->extra ? md->extra->explicitMaxSize : 0;
1269 
1270  switch (d->constraint) {
1271  case SetFixedSize:
1272  // will trigger resize
1273  mw->setFixedSize(totalSizeHint());
1274  break;
1275  case SetMinimumSize:
1276  mw->setMinimumSize(totalMinimumSize());
1277  break;
1278  case SetMaximumSize:
1279  mw->setMaximumSize(totalMaximumSize());
1280  break;
1281  case SetMinAndMaxSize:
1282  mw->setMinimumSize(totalMinimumSize());
1283  mw->setMaximumSize(totalMaximumSize());
1284  break;
1285  case SetDefaultConstraint: {
1286  bool widthSet = explMin & Qt::Horizontal;
1287  bool heightSet = explMin & Qt::Vertical;
1288  if (mw->isWindow()) {
1289  QSize ms = totalMinimumSize();
1290  if (widthSet)
1291  ms.setWidth(mw->minimumSize().width());
1292  if (heightSet)
1293  ms.setHeight(mw->minimumSize().height());
1294  if ((!heightSet || !widthSet) && hasHeightForWidth()) {
1295  int h = minimumHeightForWidth(ms.width());
1296  if (h > ms.height()) {
1297  if (!heightSet)
1298  ms.setHeight(0);
1299  if (!widthSet)
1300  ms.setWidth(0);
1301  }
1302  }
1303  mw->setMinimumSize(ms);
1304  } else if (!widthSet || !heightSet) {
1305  QSize ms = mw->minimumSize();
1306  if (!widthSet)
1307  ms.setWidth(0);
1308  if (!heightSet)
1309  ms.setHeight(0);
1310  mw->setMinimumSize(ms);
1311  }
1312  break;
1313  }
1314  case SetNoConstraint:
1315  break;
1316  }
1317 
1318  d->doResize(mw->size());
1319 
1320  if (md->extra) {
1321  md->extra->explicitMinSize = explMin;
1322  md->extra->explicitMaxSize = explMax;
1323  }
1324  // ideally only if sizeHint() or sizePolicy() has changed
1325  mw->updateGeometry();
1326  return true;
1327 }
1328 
1379 {
1380  int i = 0;
1381  QLayoutItem *item = itemAt(i);
1382  while (item) {
1383  if (item->widget() == widget)
1384  return i;
1385  ++i;
1386  item = itemAt(i);
1387  }
1388  return -1;
1389 }
1390 
1436 {
1437  Q_D(QLayout);
1438  if (constraint == d->constraint)
1439  return;
1440 
1441  d->constraint = constraint;
1442  invalidate();
1443 }
1444 
1446 {
1447  Q_D(const QLayout);
1448  return d->constraint;
1449 }
1450 
1460 {
1461  QSize s = sizeHint();
1462  Qt::Alignment a = alignment();
1463 
1464  /*
1465  This is a hack to obtain the real maximum size, not
1466  QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX), the value consistently
1467  returned by QLayoutItems that have an alignment.
1468  */
1469  QLayout *that = const_cast<QLayout *>(this);
1470  that->setAlignment(0);
1471  QSize ms = that->maximumSize();
1472  that->setAlignment(a);
1473 
1474  if ((expandingDirections() & Qt::Horizontal) ||
1475  !(a & Qt::AlignHorizontal_Mask)) {
1476  s.setWidth(qMin(r.width(), ms.width()));
1477  }
1478  if ((expandingDirections() & Qt::Vertical) ||
1479  !(a & Qt::AlignVertical_Mask)) {
1480  s.setHeight(qMin(r.height(), ms.height()));
1481  } else if (hasHeightForWidth()) {
1482  int hfw = heightForWidth(s.width());
1483  if (hfw < s.height())
1484  s.setHeight(qMin(hfw, ms.height()));
1485  }
1486 
1487  s = s.boundedTo(r.size());
1488  int x = r.x();
1489  int y = r.y();
1490 
1491  if (a & Qt::AlignBottom)
1492  y += (r.height() - s.height());
1493  else if (!(a & Qt::AlignTop))
1494  y += (r.height() - s.height()) / 2;
1495 
1496  QWidget *parent = parentWidget();
1498  if (a & Qt::AlignRight)
1499  x += (r.width() - s.width());
1500  else if (!(a & Qt::AlignLeft))
1501  x += (r.width() - s.width()) / 2;
1502 
1503  return QRect(x, y, s.width(), s.height());
1504 }
1505 
1517 {
1518  int i = 0;
1519  QLayoutItem *child;
1520  while ((child = itemAt(i))) {
1521  if (child->widget() == widget) {
1522  delete takeAt(i);
1523  invalidate();
1524  } else {
1525  ++i;
1526  }
1527  }
1528 }
1529 
1540 {
1541  int i = 0;
1542  QLayoutItem *child;
1543  while ((child = itemAt(i))) {
1544  if (child == item) {
1545  takeAt(i);
1546  invalidate();
1547  } else {
1548  ++i;
1549  }
1550  }
1551 }
1552 
1563 void QLayout::setEnabled(bool enable)
1564 {
1565  Q_D(QLayout);
1566  d->enabled = enable;
1567 }
1568 
1575 {
1576  Q_D(const QLayout);
1577  return d->enabled;
1578 }
1579 
1587 {
1588  QSize result = size.boundedTo(qSmartMaxSize(widget));
1589  result = result.expandedTo(qSmartMinSize(widget));
1590  QLayout *l = widget->layout();
1591  if (l && l->hasHeightForWidth() && result.height() < l->minimumHeightForWidth(result.width()) ) {
1592  QSize current = widget->size();
1593  int currentHfw = l->minimumHeightForWidth(current.width());
1594  int newHfw = l->minimumHeightForWidth(result.width());
1595  if (current.height() < currentHfw || currentHfw == newHfw) {
1596  //handle the constant hfw case and the vertical-only case, as well as the
1597  // current-size-is-not-correct case
1598  result.setHeight(newHfw);
1599  } else {
1600  // binary search; assume hfw is decreasing ###
1601 
1602  int maxw = qMax(widget->width(),result.width());
1603  int maxh = qMax(widget->height(), result.height());
1604  int minw = qMin(widget->width(),result.width());
1605  int minh = qMin(widget->height(), result.height());
1606 
1607  int minhfw = l->minimumHeightForWidth(minw);
1608  int maxhfw = l->minimumHeightForWidth(maxw);
1609  while (minw < maxw) {
1610  if (minhfw > maxh) { //assume decreasing
1611  minw = maxw - (maxw-minw)/2;
1612  minhfw = l->minimumHeightForWidth(minw);
1613  } else if (maxhfw < minh ) { //assume decreasing
1614  maxw = minw + (maxw-minw)/2;
1615  maxhfw = l->minimumHeightForWidth(maxw);
1616  } else {
1617  break;
1618  }
1619  }
1620  result = result.expandedTo(QSize(minw, minhfw));
1621  }
1622  }
1623  return result;
1624 }
1625 
1645 {
1646  /*
1647  The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
1648  etc. In memory, we pack it onto the available bits (CTSize) in
1649  setControlType(), and unpack it here.
1650 
1651  Example:
1652 
1653  0x00000001 maps to 0x00000000
1654  0x00000002 maps to 0x00000200
1655  0x00000004 maps to 0x00000400
1656  0x00000008 maps to 0x00000600
1657  etc.
1658  */
1659 
1660  int i = 0;
1661  while (true) {
1662  if (type & (0x1 << i)) {
1663  data = (data & ~CTMask) | (i << CTShift);
1664  return;
1665  }
1666  ++i;
1667  }
1668 }
1669 
1671 {
1672  return QSizePolicy::ControlType(0x1 << ((data & CTMask) >> CTShift));
1673 }
1674 
1675 #ifndef QT_NO_DATASTREAM
1676 
1688 {
1689  return stream << policy.data;
1690 }
1691 
1704 {
1705  return stream >> policy.data;
1706 }
1707 #endif // QT_NO_DATASTREAM
1708 
T qobject_cast(QObject *object)
Definition: qobject.h:375
double d
Definition: qnumeric_p.h:62
QSize maximumSize
the widget&#39;s maximum size in pixels
Definition: qwidget.h:173
static Qt::LayoutDirection layoutDirection()
QSize minimumSize
the widget&#39;s minimum size
Definition: qwidget.h:172
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setEnabled(bool)
Enables this layout if enable is true, otherwise disables it.
Definition: qlayout.cpp:1563
int totalHeightForWidth(int w) const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:823
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh, const QGraphicsWidget *widget, bool heightForWidth=true)
Used to calculate the Precondition: widget should support either hfw or wfh.
int type
Definition: qmetatype.cpp:239
virtual int heightForWidth(int) const
Returns the preferred height for this widget, given the width w.
Definition: qwidget.cpp:10241
short rightmargin
Definition: qwidget_p.h:746
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setSpacing(int)
Definition: qlayout.cpp:469
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
short topmargin
Definition: qwidget_p.h:745
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
QWidget * menubar
Definition: qlayout_p.h:96
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
virtual bool isEmpty() const =0
Implemented in subclasses to return whether this item is empty, i.
void setLayout(QLayout *)
Sets the layout manager for this widget to layout.
Definition: qwidget.cpp:10104
bool isVisible() const
Definition: qwidget.h:1005
QRect contentsRect() const
Returns the layout&#39;s geometry() rectangle, but taking into account the contents margins.
Definition: qlayout.cpp:591
Q_GUI_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align)
static bool layoutDebug()
Definition: qlayout.cpp:995
bool isEnabled() const
Returns true if the layout is enabled; otherwise returns false.
Definition: qlayout.cpp:1574
virtual void addItem(QLayoutItem *)=0
Implemented in subclasses to add an item.
virtual void invalidate()
Invalidates any cached information in this layout item.
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const
Definition: qlayout.cpp:168
void removeItem(QLayoutItem *)
Removes the layout item item from the layout.
Definition: qlayout.cpp:1539
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
static int menuBarHeightForWidth(QWidget *menubar, int w)
Definition: qlayout.cpp:58
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition: qlayout.cpp:1249
virtual int minimumHeightForWidth(int) const
Returns the minimum height this widget needs for the given width, w.
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
long ASN1_INTEGER_get ASN1_INTEGER * a
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
static QWidgetItemFactoryMethod widgetItemFactoryMethod
Definition: qlayout_p.h:82
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QSpacerItemFactoryMethod spacerItemFactoryMethod
Definition: qlayout_p.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
QWidget * menuBar() const
Returns the menu bar set for this layout, or 0 if no menu bar is set.
Definition: qlayout.cpp:1149
static QSize closestAcceptableSize(const QWidget *w, const QSize &s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is ...
Definition: qlayout.cpp:1586
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const char * className
Definition: qwizard.cpp:137
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
Qt::Orientations expandingDirections() const
Returns whether this layout can make use of more space than sizeHint().
Definition: qlayout.cpp:1198
#define Q_Q(Class)
Definition: qglobal.h:2483
QSize maximumSize() const
Returns the maximum size of this layout.
Definition: qlayout.cpp:1181
int top() const
Returns the top margin.
Definition: qmargins.h:99
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QWidget * parentWidget() const
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget...
Definition: qlayout.cpp:616
#define QT_RETHROW
Definition: qglobal.h:1539
int width() const
Returns the width.
Definition: qsize.h:126
virtual QLayoutItem * takeAt(int index)=0
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item.
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
quint32 data
Definition: qsizepolicy.h:204
QSize totalMaximumSize() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:902
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static FILE * stream
QLayout()
Constructs a new child QLayout.
Definition: qlayout.cpp:127
bool adoptLayout(QLayout *layout)
Definition: qlayout.cpp:987
QWidgetItem *(* QWidgetItemFactoryMethod)(const QLayout *layout, QWidget *widget)
Definition: qlayout_p.h:70
The QSpacerItem class provides blank space in a layout.
Definition: qlayoutitem.h:96
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
virtual int indexOf(QWidget *) const
Searches for widget widget in this layout (not including child layouts).
Definition: qlayout.cpp:1378
void update()
Updates the layout for parentWidget().
Definition: qlayout.cpp:1225
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
const char * name
~QLayout()
Destroys the layout, deleting all child layouts.
Definition: qlayout.cpp:936
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const char * layout
QMargins contentsMargins() const
Returns the margins used around the layout.
Definition: qlayout.cpp:573
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
short leftmargin
Definition: qwidget_p.h:744
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
Definition: qlayout.cpp:198
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
void setMenuBar(QWidget *w)
Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins().
Definition: qlayout.cpp:1131
QSpacerItem *(* QSpacerItemFactoryMethod)(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy)
Definition: qlayout_p.h:71
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
QLayout::SizeConstraint constraint
Definition: qlayout_p.h:94
#define QT_CATCH(A)
Definition: qglobal.h:1537
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
QRect alignmentRect(const QRect &) const
Returns the rectangle that should be covered when the geometry of this layout is set to r...
Definition: qlayout.cpp:1459
static QWidget * parentWidget(const QWidget *w)
bool isEmpty() const
Reimplemented Function
Definition: qlayout.cpp:639
static void activateRecursiveHelper(QLayoutItem *item)
Definition: qlayout.cpp:1203
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
uint explicitMaxSize
Definition: qwidget_p.h:274
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
Definition: qlayout.cpp:190
SizeConstraint
The possible values are:
Definition: qlayout.h:100
int minimumWidth
the widget&#39;s minimum width in pixels
Definition: qwidget.h:174
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition: qstyle.cpp:2149
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
void setControlType(ControlType type)
Definition: qlayout.cpp:1644
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition: qwidget.cpp:4284
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
Definition: qlayout.cpp:1045
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Definition: qlayout.cpp:551
QDataStream & operator>>(QDataStream &s, QAxBase &c)
Definition: qaxbase.h:189
QSize totalSizeHint() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:874
void addChildLayout(QLayout *l)
This function is called from addLayout() or insertLayout() functions in subclasses to add layout l as...
Definition: qlayout.cpp:969
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFactoryLoader * l
QWExtra * extra
Definition: qwidget_p.h:700
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
QSize minimumSize() const
Returns the minimum size of this layout.
Definition: qlayout.cpp:1166
QObject * parent
Definition: qobject.h:92
short bottommargin
Definition: qwidget_p.h:747
void setContentsMargins(int left, int top, int right, int bottom)
Sets the left, top, right, and bottom margins to use around the layout.
Definition: qlayout.cpp:502
QSize totalMinimumSize() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:848
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QDataStream & operator<<(QDataStream &s, const QAxBase &c)
Definition: qaxbase.h:203
The QFormLayout class manages forms of input widgets and their associated labels. ...
Definition: qformlayout.h:55
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
int left() const
Returns the left margin.
Definition: qmargins.h:96
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void setSizeConstraint(SizeConstraint)
Definition: qlayout.cpp:1435
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
static bool removeWidgetRecursively(QLayoutItem *li, QWidget *w)
Definition: qlayout.cpp:680
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
Definition: qwidget.cpp:10372
QRect geometry() const
Reimplemented Function
Definition: qlayout.cpp:664
int margin() const
void widgetEvent(QEvent *)
Performs child widget layout when the parent widget is resized.
Definition: qlayout.cpp:726
The QMargins class defines the four margins of a rectangle.
Definition: qmargins.h:53
static const int QLAYOUTSIZE_MAX
Definition: qlayoutitem.h:56
void setMargin(int)
Definition: qlayout.cpp:464
void doResize(const QSize &)
Definition: qlayout.cpp:702
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
#define qPrintable(string)
Definition: qglobal.h:1750
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
ControlType controlType() const
Definition: qlayout.cpp:1670
int bottom() const
Returns the bottom margin.
Definition: qmargins.h:105
SizeConstraint sizeConstraint() const
#define QT_TRY
Definition: qglobal.h:1536
int right() const
Returns the right margin.
Definition: qmargins.h:102
void childEvent(QChildEvent *e)
Reimplemented Function
Definition: qlayout.cpp:793
#define enabled
bool 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 inclu...
Definition: qlayout.cpp:332
void reparentChildWidgets(QWidget *mw)
Definition: qlayout.cpp:1005
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QObject * child() const
Returns the child object that was added or removed.
Definition: qcoreevent.h:358
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition: qlayout.cpp:1516
uint explicitMinSize
Definition: qwidget_p.h:273