Qt 4.8
Functions
qlayout.cpp File Reference
#include "qlayout.h"
#include "qapplication.h"
#include "qlayoutengine_p.h"
#include "qmenubar.h"
#include "qtoolbar.h"
#include "qsizegrip.h"
#include "qevent.h"
#include "qstyle.h"
#include "qvariant.h"
#include "qwidget_p.h"
#include "qlayout_p.h"
#include "qformlayout.h"

Go to the source code of this file.

Functions

static bool layoutDebug ()
 
static int menuBarHeightForWidth (QWidget *menubar, int w)
 
static bool removeWidgetRecursively (QLayoutItem *li, QWidget *w)
 

Function Documentation

◆ layoutDebug()

static bool layoutDebug ( )
static

Definition at line 995 of file qlayout.cpp.

Referenced by QLayout::addChildWidget(), and QLayoutPrivate::reparentChildWidgets().

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 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
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...

◆ menuBarHeightForWidth()

static int menuBarHeightForWidth ( QWidget menubar,
int  w 
)
static

Definition at line 58 of file qlayout.cpp.

Referenced by QLayoutPrivate::doResize(), QLayout::totalHeightForWidth(), QLayout::totalMaximumSize(), QLayout::totalMinimumSize(), and QLayout::totalSizeHint().

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 }
QSize maximumSize
the widget's maximum size in pixels
Definition: qwidget.h:173
virtual int heightForWidth(int) const
Returns the preferred height for this widget, given the width w.
Definition: qwidget.cpp:10241
Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
int minimumWidth
the widget's minimum width in pixels
Definition: qwidget.h:174
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
int height() const
Returns the height.
Definition: qsize.h:129
QSize sizeHint
the recommended size for the widget
Definition: qwidget.h:195

◆ removeWidgetRecursively()

static bool removeWidgetRecursively ( QLayoutItem li,
QWidget w 
)
static

Definition at line 680 of file qlayout.cpp.

Referenced by QLayout::addChildWidget(), and QLayout::widgetEvent().

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 }
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
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.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
static bool removeWidgetRecursively(QLayoutItem *li, QWidget *w)
Definition: qlayout.cpp:680