本文整理汇总了C++中QStyle::combinedLayoutSpacing方法的典型用法代码示例。如果您正苦于以下问题:C++ QStyle::combinedLayoutSpacing方法的具体用法?C++ QStyle::combinedLayoutSpacing怎么用?C++ QStyle::combinedLayoutSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStyle
的用法示例。
在下文中一共展示了QStyle::combinedLayoutSpacing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupGeom
/*
Initializes the data structure needed by qGeomCalc and
recalculates max/min and size hint.
*/
void QBoxLayoutPrivate::setupGeom()
{
if (!dirty)
return;
Q_Q(QBoxLayout);
int maxw = horz(dir) ? 0 : QLAYOUTSIZE_MAX;
int maxh = horz(dir) ? QLAYOUTSIZE_MAX : 0;
int minw = 0;
int minh = 0;
int hintw = 0;
int hinth = 0;
bool horexp = false;
bool verexp = false;
hasHfw = false;
int n = list.count();
geomArray.clear();
QVector<QLayoutStruct> a(n);
QSizePolicy::ControlTypes controlTypes1;
QSizePolicy::ControlTypes controlTypes2;
int fixedSpacing = q->spacing();
int previousNonEmptyIndex = -1;
QStyle *style = 0;
if (fixedSpacing < 0) {
if (QWidget *parentWidget = q->parentWidget())
style = parentWidget->style();
}
for (int i = 0; i < n; i++) {
QBoxLayoutItem *box = list.at(i);
QSize max = box->item->maximumSize();
QSize min = box->item->minimumSize();
QSize hint = box->item->sizeHint();
Qt::Orientations exp = box->item->expandingDirections();
bool empty = box->item->isEmpty();
int spacing = 0;
if (!empty) {
if (fixedSpacing >= 0) {
spacing = (previousNonEmptyIndex >= 0) ? fixedSpacing : 0;
#ifdef Q_WS_MAC
if (!horz(dir) && previousNonEmptyIndex >= 0) {
QBoxLayoutItem *sibling = (dir == QBoxLayout::TopToBottom ? box : list.at(previousNonEmptyIndex));
if (sibling) {
QWidget *wid = sibling->item->widget();
if (wid)
spacing = qMax(spacing, sibling->item->geometry().top() - wid->geometry().top());
}
}
#endif
} else {
controlTypes1 = controlTypes2;
controlTypes2 = box->item->controlTypes();
if (previousNonEmptyIndex >= 0) {
QSizePolicy::ControlTypes actual1 = controlTypes1;
QSizePolicy::ControlTypes actual2 = controlTypes2;
if (dir == QBoxLayout::RightToLeft || dir == QBoxLayout::BottomToTop)
qSwap(actual1, actual2);
if (style) {
spacing = style->combinedLayoutSpacing(actual1, actual2,
horz(dir) ? Qt::Horizontal : Qt::Vertical,
0, q->parentWidget());
if (spacing < 0)
spacing = 0;
}
}
}
if (previousNonEmptyIndex >= 0)
a[previousNonEmptyIndex].spacing = spacing;
previousNonEmptyIndex = i;
}
bool ignore = empty && box->item->widget(); // ignore hidden widgets
bool dummy = true;
if (horz(dir)) {
bool expand = (exp & Qt::Horizontal || box->stretch > 0);
horexp = horexp || expand;
maxw += spacing + max.width();
minw += spacing + min.width();
hintw += spacing + hint.width();
if (!ignore)
qMaxExpCalc(maxh, verexp, dummy,
max.height(), exp & Qt::Vertical, box->item->isEmpty());
minh = qMax(minh, min.height());
hinth = qMax(hinth, hint.height());
a[i].sizeHint = hint.width();
a[i].maximumSize = max.width();
a[i].minimumSize = min.width();
//.........这里部分代码省略.........