Qt 4.8
Classes | Functions
qgridlayout.cpp File Reference
#include "qgridlayout.h"
#include "qapplication.h"
#include "qwidget.h"
#include "qlist.h"
#include "qsizepolicy.h"
#include "qvector.h"
#include "qvarlengtharray.h"
#include "qlayoutengine_p.h"
#include "qlayout_p.h"

Go to the source code of this file.

Classes

class  QGridBox
 
class  QGridLayoutPrivate
 
struct  QGridLayoutSizeTriple
 

Functions

static bool checkWidget (QLayout *l, QWidget *w)
 
static void distributeMultiBox (QVector< QLayoutStruct > &chain, int start, int end, int minSize, int sizeHint, QVector< int > &stretchArray, int stretch)
 
static QGridBox *& gridAt (QGridBox *grid[], int r, int c, int cc, Qt::Orientation orientation=Qt::Vertical)
 
static void initEmptyMultiBox (QVector< QLayoutStruct > &chain, int start, int end)
 

Function Documentation

◆ checkWidget()

static bool checkWidget ( QLayout l,
QWidget w 
)
static

Definition at line 1552 of file qgridlayout.cpp.

Referenced by QGridLayout::addWidget().

1553 {
1554  if (!w) {
1555  qWarning("QLayout: Cannot add null widget to %s/%s", l->metaObject()->className(),
1556  l->objectName().toLocal8Bit().data());
1557  return false;
1558  }
1559  return true;
1560 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ distributeMultiBox()

static void distributeMultiBox ( QVector< QLayoutStruct > &  chain,
int  start,
int  end,
int  minSize,
int  sizeHint,
QVector< int > &  stretchArray,
int  stretch 
)
static

Definition at line 617 of file qgridlayout.cpp.

Referenced by QGridLayoutPrivate::setupHfwLayoutData(), and QGridLayoutPrivate::setupLayoutData().

619 {
620  int i;
621  int w = 0;
622  int wh = 0;
623  int max = 0;
624 
625  for (i = start; i <= end; i++) {
626  QLayoutStruct *data = &chain[i];
627  w += data->minimumSize;
628  wh += data->sizeHint;
629  max += data->maximumSize;
630  if (stretchArray.at(i) == 0)
631  data->stretch = qMax(data->stretch, stretch);
632 
633  if (i != end) {
634  int spacing = data->spacing;
635  w += spacing;
636  wh += spacing;
637  max += spacing;
638  }
639  }
640 
641  if (max < minSize) { // implies w < minSize
642  /*
643  We must increase the maximum size of at least one of the
644  items. qGeomCalc() will put the extra space in between the
645  items. We must recover that extra space and put it
646  somewhere. It does not really matter where, since the user
647  can always specify stretch factors and avoid this code.
648  */
649  qGeomCalc(chain, start, end - start + 1, 0, minSize);
650  int pos = 0;
651  for (i = start; i <= end; i++) {
652  QLayoutStruct *data = &chain[i];
653  int nextPos = (i == end) ? minSize : chain.at(i + 1).pos;
654  int realSize = nextPos - pos;
655  if (i != end)
656  realSize -= data->spacing;
657  if (data->minimumSize < realSize)
658  data->minimumSize = realSize;
659  if (data->maximumSize < data->minimumSize)
660  data->maximumSize = data->minimumSize;
661  pos = nextPos;
662  }
663  } else if (w < minSize) {
664  qGeomCalc(chain, start, end - start + 1, 0, minSize);
665  for (i = start; i <= end; i++) {
666  QLayoutStruct *data = &chain[i];
667  if (data->minimumSize < data->size)
668  data->minimumSize = data->size;
669  }
670  }
671 
672  if (wh < sizeHint) {
673  qGeomCalc(chain, start, end - start + 1, 0, sizeHint);
674  for (i = start; i <= end; i++) {
675  QLayoutStruct *data = &chain[i];
676  if (data->sizeHint < data->size)
677  data->sizeHint = data->size;
678  }
679  }
680 }
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static const char * data(const QByteArray &arr)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
static const KeyPair *const end

◆ gridAt()

static QGridBox*& gridAt ( QGridBox grid[],
int  r,
int  c,
int  cc,
Qt::Orientation  orientation = Qt::Vertical 
)
static

Definition at line 682 of file qgridlayout.cpp.

Referenced by QGridLayoutPrivate::setupLayoutData(), and QGridLayoutPrivate::setupSpacings().

684 {
685  if (orientation == Qt::Horizontal)
686  qSwap(r, c);
687  return grid[(r * cc) + c];
688 }
unsigned char c[8]
Definition: qnumeric_p.h:62
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181

◆ initEmptyMultiBox()

static void initEmptyMultiBox ( QVector< QLayoutStruct > &  chain,
int  start,
int  end 
)
static

Definition at line 607 of file qgridlayout.cpp.

Referenced by QGridLayoutPrivate::setupHfwLayoutData(), and QGridLayoutPrivate::setupLayoutData().

608 {
609  for (int i = start; i <= end; i++) {
610  QLayoutStruct *data = &chain[i];
611  if (data->empty && data->maximumSize == 0) // truly empty box
613  data->empty = false;
614  }
615 }
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
static const char * data(const QByteArray &arr)
static const KeyPair *const end