本文整理汇总了C++中QLayoutItem::sizeHint方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayoutItem::sizeHint方法的具体用法?C++ QLayoutItem::sizeHint怎么用?C++ QLayoutItem::sizeHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayoutItem
的用法示例。
在下文中一共展示了QLayoutItem::sizeHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doLayout
int FlowLayout::doLayout ( const QRect &rect, bool testOnly ) const
{
int left, top, right, bottom;
getContentsMargins ( &left, &top, &right, &bottom );
int x = rect.x() + left;
int y = rect.y() + top;
int lineHeight = 0;
QLayoutItem *item;
Q_FOREACH ( item, itemList )
{
int nextX = x + item->sizeHint().width() + spacing();
if ( nextX - spacing() > (rect.right() - right) && lineHeight > 0 )
{
x = rect.x() + left;
y = y + lineHeight + spacing();
nextX = x + item->sizeHint().width() + spacing();
//lineHeight = 0;
}
if ( !testOnly )
item->setGeometry ( QRect ( QPoint ( x, y ), item->sizeHint() ) );
x = nextX;
lineHeight = qMax ( lineHeight, item->sizeHint().height() );
}
示例2: doLayout
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const {
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
QLayoutItem *item;
foreach (item, itemList) {
QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
}
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
示例3: doLayout
int MonitorLayout::doLayout(const QRect& rect, bool testOnly) const
{
int x = rect.x();
int y = rect.y();
int lineHeight = 0;
QLayoutItem* item;
foreach (item, m_items)
{
int nextX = x + item->sizeHint().width() + spacing();
if (nextX - spacing() > rect.right() && lineHeight > 0)
{
x = rect.x();
y = y + lineHeight + spacing();
nextX = x + item->sizeHint().width() + spacing();
lineHeight = 0;
}
if (testOnly == false)
{
item->setGeometry(QRect(QPoint(x, y),
item->sizeHint()));
}
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
示例4: sizeHint
QSize QLayoutItemProto::sizeHint() const
{
QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
if (item)
return item->sizeHint();
return QSize();
}
示例5: doLayout
void SmartVerticalFlowLayout::doLayout(const QRect &rect)
{
if (!m_isLayoutModified)
return;
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
// update structure (ordering line by lines)
m_structure.clear();
QLayoutItem* item = 0;
QList<QLayoutItem*> rowItems;
Q_FOREACH(item, m_items) {
QSize itemSize = item->sizeHint();
// if the item is over the line limit OR limit reach per row
if (x + itemSize.width() > effectiveRect.right()+1 ||
(m_maxRowCount > 0 && rowItems.count() >= m_maxRowCount)) {
// if the line isn't empty => we add to the structure
// and reset the row
if (!rowItems.isEmpty()) {
m_structure.append(rowItems);
x = effectiveRect.x();
}
rowItems.clear();
}
rowItems.append(item);
x += itemSize.width() + horizontalSpacing();
}
示例6: sizeHint
QSize StatusBarLayout::sizeHint() const
{
QSize s(0, 0);
for (int i = 0; i < m_items.size(); ++i) {
QLayoutItem* item = m_items.at(i);
s = s.expandedTo(item->sizeHint());
}
return s;
}
示例7: setGeometry
void FlagLayout::setGeometry(const QRect &rect)
{
int topHeight = 0;
int bottomHeight = 0;
QLayout::setGeometry(rect);
// left side
for (int i = 0; i < list.size(); ++i) {
ItemWrapper *wrapper = list.at(i);
QLayoutItem *item = wrapper->item;
Position position = wrapper->position;
if (position == TopLeft) {
topHeight += spacing();
item->setGeometry(QRect(rect.x() + spacing(), topHeight,
item->sizeHint().width(), item->sizeHint().height()));
topHeight += item->geometry().height();
} else if (position == BottomLeft) {
bottomHeight += item->geometry().height() + spacing();
item->setGeometry(QRect(rect.x() + spacing(), rect.height() - bottomHeight,
item->sizeHint().width(), item->sizeHint().height()));
}
}
// right side
topHeight = 0;
bottomHeight = 0;
for (int i = 0; i < list.size(); ++i) {
ItemWrapper *wrapper = list.at(i);
QLayoutItem *item = wrapper->item;
Position position = wrapper->position;
int rightpos = item->sizeHint().width() + spacing();
if (position == TopRight) {
topHeight += spacing();
item->setGeometry(QRect(rect.x() + rect.width() - rightpos, topHeight,
item->sizeHint().width(), item->sizeHint().height()));
topHeight += item->geometry().height();
} else if (position == BottomRight) {
bottomHeight += item->geometry().height() + spacing();
item->setGeometry(QRect(rect.x() + rect.width() - rightpos, rect.height() - bottomHeight,
item->sizeHint().width(), item->sizeHint().height()));
}
}
}
示例8: setGeometry
void FreeLayout::setGeometry(const QRect &r)
{
QList<QLayoutItem *>::const_iterator it, iEnd = m_items.end();
for (it = m_items.begin(); it != iEnd; ++it) {
QLayoutItem *item = *it;
const QRect &geom = item->geometry();
const QSize &sizeHint = item->sizeHint();
if (geom.size() != sizeHint)
item->setGeometry(QRect(geom.topLeft(), sizeHint));
}
}
示例9: sizeHint
QSize FlowLayout::sizeHint() const
{
QSize s(0,0);
QPtrListIterator<QLayoutItem> it(_list);
QLayoutItem *o;
while ( (o=it.current()) != 0 )
{
++it;
s = s.expandedTo( o->sizeHint() );
}
return s;
}
示例10: doLayout
int SimpleFlow::doLayout( const QRect &r, bool testonly )
{
int x = r.x();
int y = r.y();
int h = 0; //height of this line so far.
QPtrListIterator<QLayoutItem> it(list);
QLayoutItem *o;
while ( (o=it.current()) != 0 ) {
++it;
int nextX = x + o->sizeHint().width() + spacing();
if ( nextX - spacing() > r.right() && h > 0 ) {
x = r.x();
y = y + h + spacing();
nextX = x + o->sizeHint().width() + spacing();
h = 0;
}
if ( !testonly )
o->setGeometry( QRect( QPoint( x, y ), o->sizeHint() ) );
x = nextX;
h = QMAX( h, o->sizeHint().height() );
}
return y + h - r.y();
}
示例11: sizeHint
//! [7]
QSize CardLayout::sizeHint() const
{
QSize s(0,0);
int n = list.count();
if (n > 0)
s = QSize(100,70); //start with a nice default size
int i = 0;
while (i < n) {
QLayoutItem *o = list.at(i);
s = s.expandedTo(o->sizeHint());
++i;
}
return s + n*QSize(spacing(), spacing());
}
示例12: doLayoutHorizontal
int FlowLayout::doLayoutHorizontal( const QRect &r, bool testonly )
{
int x = r.x();
int y = r.y();
int w = 0;
QPtrListIterator<QLayoutItem> it(_list);
QLayoutItem *o;
while ( (o=it.current()) != 0 )
{
++it;
int nextY = y + o->sizeHint().height() + spacing();
if ( nextY - spacing() > r.bottom() && w > 0 )
{
y = r.y();
x = x + w + spacing();
nextY = y + o->sizeHint().height() + spacing();
w = 0;
}
if ( !testonly )
{
QRect oR(QPoint( x, y ), o->sizeHint());
if (oR.bottom() > r.bottom() )
oR.setBottom(r.bottom());
o->setGeometry( oR );
}
y = nextY;
w = QMAX( w, o->sizeHint().width() );
}
return x + w - r.x();
}
示例13: doLayoutVertical
int FlowLayout::doLayoutVertical( const QRect &r, bool testonly )
{
int x = r.x();
int y = r.y();
int h = 0;
QPtrListIterator<QLayoutItem> it(_list);
QLayoutItem *o;
while ( (o=it.current()) != 0 )
{
++it;
int nextX = x + o->sizeHint().width() + spacing();
if ( nextX - spacing() > r.right() && h > 0 )
{
x = r.x();
y = y + h + spacing();
nextX = x + o->sizeHint().width() + spacing();
h = 0;
}
if ( !testonly )
{
QRect oR(QPoint( x, y ), o->sizeHint());
if (oR.right() > r.right() )
oR.setRight(r.right());
o->setGeometry( oR );
}
x = nextX;
h = QMAX( h, o->sizeHint().height() );
}
return y + h - r.y();
}
示例14: sizeHint
QSize DummyLayout::sizeHint() const
{
QRect geom, result;
QList<QLayoutItem *>::const_iterator it, iEnd = m_items.end();
for (it = m_items.begin(); it != iEnd; ++it) {
QLayoutItem *item = *it;
geom = item->geometry();
geom.setSize(item->sizeHint());
result |= geom;
}
return result.size();
}
示例15: setGeometry
void OverlayLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
if (list.size() == 0)
return;
int i = 0;
while (i < list.size())
{
QLayoutItem *o = list.at(i);
if (i == 0)
{
o->setGeometry(rect);
}
else
{
auto size = o->sizeHint();
QRect geom(rect.x() + rect.width() - size.width(), rect.y(), size.width(), size.height());
o->setGeometry(geom);
}
++i;
}
}