本文整理汇总了C++中QLayoutItem::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayoutItem::isEmpty方法的具体用法?C++ QLayoutItem::isEmpty怎么用?C++ QLayoutItem::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayoutItem
的用法示例。
在下文中一共展示了QLayoutItem::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEmpty
bool QLayoutItemProto::isEmpty() const
{
QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
if (item)
return item->isEmpty();
return false;
}
示例2: reorderGridLayout
void reorderGridLayout(QGridLayout* layout, int maxCols)
{
QList<QLayoutItem*> items;
for (int i = 0; i < layout->rowCount(); i++) {
for (int j = 0; j < layout->columnCount(); j++) {
QLayoutItem* item = layout->itemAtPosition(i, j);
if (item) {
layout->removeItem(item);
if (item->isEmpty()) {
delete item;
}
else {
items.append(item);
}
}
}
}
int col = 0, row = 0;
while (!items.isEmpty()) {
QLayoutItem* item = items.takeAt(0);
layout->addItem(item, row, col);
col++;
if (col >= maxCols) {
col = 0;
row++;
}
}
}
示例3: arrange
// Arranges widgets and returns height required.
int PackedLayout::arrange(const QRect& rect, bool set) const
{
int x = rect.x();
int y = rect.y();
int yrow = 0;
QList<QRect> posn;
int end = mItems.count();
QList<QLayoutItem*> items;
for (int i = 0; i < end; ++i)
{
QLayoutItem* item = mItems[i];
if (item->isEmpty())
continue;
QSize size = item->sizeHint();
int right = x + size.width();
if (right > rect.right() && x > rect.x())
{
x = rect.x();
y = y + yrow + spacing();
right = x + size.width();
yrow = size.height();
}
else
yrow = qMax(yrow, size.height());
items.append(item);
posn.append(QRect(QPoint(x, y), size));
x = right + spacing();
}
if (set)
{
int count = items.count();
if (mAlignment == Qt::AlignLeft)
{
// Left aligned: no position adjustment needed
// Set the positions of all the layout items
for (int i = 0; i < count; ++i)
items[i]->setGeometry(posn[i]);
}
else
{
// Set the positions of all the layout items
for (int i = 0; i < count; )
{
// Adjust item positions a row at a time
y = posn[i].y();
int last; // after last item in this row
for (last = i + 1; last < count && posn[last].y() == y; ++last) ;
int n = last - i; // number of items in this row
int free = rect.right() - posn[last - 1].right();
switch (mAlignment)
{
case Qt::AlignJustify:
if (n == 1)
{
items[i]->setGeometry(posn[i]);
++i;
}
else if (n > 1)
{
for (int j = 0; i < last; ++j, ++i)
items[i]->setGeometry(QRect(QPoint(posn[i].x() + (free * j)/(n - 1), y), posn[i].size()));
}
break;
case Qt::AlignHCenter:
free /= 2;
// fall through to AlignRight
case Qt::AlignRight:
for ( ; i < last; ++i)
items[i]->setGeometry(QRect(QPoint(posn[i].x() + free, y), posn[i].size()));
break;
default:
break;
}
}
}
}
return y + yrow - rect.y();
}