当前位置: 首页>>代码示例>>C++>>正文


C++ QLayoutItem::sizeHint方法代码示例

本文整理汇总了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() );
	}
开发者ID:Andrsid,项目名称:myagent-im,代码行数:27,代码来源:flowlayout.cpp

示例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());
    }
开发者ID:nobodyzzz,项目名称:leechcraft,代码行数:34,代码来源:FlowLayout.cpp

示例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());
    }
开发者ID:Andersbakken,项目名称:qlc-svn,代码行数:27,代码来源:monitorlayout.cpp

示例4: sizeHint

QSize QLayoutItemProto::sizeHint() const
{
  QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
  if (item)
    return item->sizeHint();
  return QSize();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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();
    }
开发者ID:VaysseB,项目名称:SmartVerticalFlowLayout,代码行数:33,代码来源:smartverticalflowlayout.cpp

示例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;
}
开发者ID:KDE,项目名称:kimtoy,代码行数:9,代码来源:statusbarlayout.cpp

示例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()));
        }
    }
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:48,代码来源:Flag.cpp

示例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));
	}
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:13,代码来源:freelayout.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:lapsus-svn,代码行数:14,代码来源:flowlayout.cpp

示例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();
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:23,代码来源:flow.cpp

示例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());
}
开发者ID:lifeIsGame,项目名称:phantomjs,代码行数:15,代码来源:doc_src_layout.cpp

示例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();
}
开发者ID:BackupTheBerlios,项目名称:lapsus-svn,代码行数:37,代码来源:flowlayout.cpp

示例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();
}
开发者ID:BackupTheBerlios,项目名称:lapsus-svn,代码行数:36,代码来源:flowlayout.cpp

示例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();
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:16,代码来源:freelayout.cpp

示例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;
    }
}
开发者ID:DestroyFX,项目名称:EveLogLite,代码行数:24,代码来源:overlaylayout.cpp


注:本文中的QLayoutItem::sizeHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。