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


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

本文整理汇总了C++中QLayoutItem::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayoutItem::setGeometry方法的具体用法?C++ QLayoutItem::setGeometry怎么用?C++ QLayoutItem::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLayoutItem的用法示例。


在下文中一共展示了QLayoutItem::setGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: doLayout

int UFlowLayout::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:gauldoth,项目名称:UniCore,代码行数:34,代码来源:UFlowLayout.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: 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

示例5: setGeometry

void FlowLayout::setGeometry(const QRect &rect)
{
	if (itemList.isEmpty())
		return;

	QLayout::setGeometry(rect);

	int itemWidth = itemList.at(0)->sizeHint().width();
	int itemHeight = itemList.at(0)->sizeHint().height();

	int x = rect.x() + margin();
	int y = rect.y() + margin();

	QLayoutItem *item;
	foreach (item, itemList)
	{
		if ((x + itemWidth) > (rect.right() - margin()))
		{
			x = rect.x() + margin();
			y = y + itemHeight + spacing();
		}

		item->setGeometry(QRect(QPoint(x, y), QSize(itemWidth, itemHeight)));

		x = x + itemWidth + spacing();
	}

	emit rearranged();
}
开发者ID:igusGmbH,项目名称:igusMotionEditor,代码行数:29,代码来源:FlowLayout.cpp

示例6: 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

示例7: 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

示例8: setGeometry

//! [6]
void CardLayout::setGeometry(const QRect &r)
{
    QLayout::setGeometry(r);

    if (list.size() == 0)
        return;

    int w = r.width() - (list.count() - 1) * spacing();
    int h = r.height() - (list.count() - 1) * spacing();
    int i = 0;
    while (i < list.size()) {
        QLayoutItem *o = list.at(i);
        QRect geom(r.x() + i * spacing(), r.y() + i * spacing(), w, h);
        o->setGeometry(geom);
        ++i;
    }
}
开发者ID:lifeIsGame,项目名称:phantomjs,代码行数:18,代码来源:doc_src_layout.cpp

示例9: 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

示例10: 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

示例11: 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

示例12: 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;

    auto spacingX = [this]( QLayoutItem *item ) {
        int spaceX = horizontalSpacing();
        if( spaceX == -1 ) {
            QWidget *widget = item->widget();
            if( widget ) {
                return widget->style()->layoutSpacing(
                           QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal
                       );
            }
            return 0;
        }
        return spaceX;
    };
    auto spacingY = [this]( QLayoutItem *item ) {
        int spaceY = verticalSpacing();
        if( spaceY == -1 ) {
            QWidget *widget = item->widget();
            if( widget ) {
                return widget->style()->layoutSpacing(
                           QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical
                       );
            }
            return 0;
        }
        return spaceY;
    };

    for( auto iter = itemList.begin(), endLine = iter; iter != itemList.end(); ) {
        if( iter == endLine ) {
            x = effectiveRect.x();

            int lineWidth = 0;
            for( ; endLine != itemList.end(); ++endLine ) {
                QLayoutItem *item = *endLine;
                int itemWidth = spacingX( item ) + item->sizeHint().width();
                if( itemWidth+lineWidth > effectiveRect.width() && lineWidth > 0 ) {
                    break;
                }
                lineWidth += itemWidth;
            }

            x += qMax( (effectiveRect.width()-lineWidth) / 2, 0 );
            y += lineHeight;
            lineHeight = 0;
        }


        for( ; iter != endLine; ++iter ) {
            QLayoutItem *item = *iter;
            int spaceX = spacingX( item );
            int spaceY = spacingY( item );

            if( !testOnly ) {
                item->setGeometry( QRect(QPoint(x,y), item->sizeHint()) );
            }

            x += spaceX + item->sizeHint().width();
            lineHeight = qMax( lineHeight, item->sizeHint().height()+spaceY );

        }
    }

    return y + lineHeight - rect.y() + bottom;
}
开发者ID:Visse,项目名称:StreamingPlayer,代码行数:73,代码来源:FlowLayout.cpp

示例13: setGeometry

void ZBorderLayout::setGeometry(const QRect &rect)
{
    ItemWrapper *center = 0;
    int eastWidth = 0;
    int westWidth = 0;
    int northHeight = 0;
    int southHeight = 0;
    int centerHeight = 0;
    int i;

    QLayout::setGeometry(rect);

    for (i = 0; i < list.size(); ++i) {
        ItemWrapper *wrapper = list.at(i);
        QLayoutItem *item = wrapper->item;
        Position position = wrapper->position;

        if (position == North) {
            item->setGeometry(QRect(rect.x(), northHeight, rect.width(),
                                    item->sizeHint().height()));

            northHeight += item->geometry().height() + spacing();
        } else if (position == South) {
            item->setGeometry(QRect(item->geometry().x(),
                                    item->geometry().y(), rect.width(),
                                    item->sizeHint().height()));

            southHeight += item->geometry().height() + spacing();

            item->setGeometry(QRect(rect.x(),
                              rect.y() + rect.height() - southHeight + spacing(),
                              item->geometry().width(),
                              item->geometry().height()));
        } else if (position == Center) {
            center = wrapper;
        }
    }

    centerHeight = rect.height() - northHeight - southHeight;

    for (i = 0; i < list.size(); ++i) {
        ItemWrapper *wrapper = list.at(i);
        QLayoutItem *item = wrapper->item;
        Position position = wrapper->position;

        if (position == West) {
            item->setGeometry(QRect(rect.x() + westWidth, northHeight,
                                    item->sizeHint().width(), centerHeight));

            westWidth += item->geometry().width() + spacing();
        } else if (position == East) {
            item->setGeometry(QRect(item->geometry().x(), item->geometry().y(),
                                    item->sizeHint().width(), centerHeight));

            eastWidth += item->geometry().width() + spacing();

            item->setGeometry(QRect(
                              rect.x() + rect.width() - eastWidth + spacing(),
                              northHeight, item->geometry().width(),
                              item->geometry().height()));
        }
    }

    if (center)
        center->item->setGeometry(QRect(westWidth, northHeight,
                                        rect.width() - eastWidth - westWidth,
                                        centerHeight));
}
开发者ID:ghetzel,项目名称:zee,代码行数:68,代码来源:zborderlayout.cpp

示例14: setGeometry

void QLayoutItemProto::setGeometry(const QRect &r)
{
  QLayoutItem *item = qscriptvalue_cast<QLayoutItem*>(thisObject());
  if (item)
    item->setGeometry(r);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例15: refreshLayout

void MosaicLayout::refreshLayout(const QRect& rect)
{ 
  //item size
  int itemHSize, itemVSize;
  int totalSpacing = spacing() * itemsList.count();
  // horizontal max number of items
  int HMaxItems = contentsRect().width() / (minItemHSize + totalSpacing);  
  bool oneRow = false;
  if (HMaxItems >= itemsList.count()) 
  {
    HMaxItems = itemsList.count(); 
    if (HMaxItems == 0)
      HMaxItems += 1; // one avoid division by 0
    oneRow = true;
  }
  // horizontal dimension that could be added to each item
  // since there is room
  int HPlusSize = ( contentsRect().width()  -
  (minItemHSize * HMaxItems) ) / HMaxItems;
  //TODO: check this, too many operations
  if (oneRow)  
  {
    if (minItemHSize + HPlusSize > maxItemHSize)
      itemHSize = maxItemHSize;
    else
      itemHSize = minItemHSize + HPlusSize;
  }
  else {
    if (HPlusSize + minItemHSize > maxItemHSize)
      itemHSize = minItemHSize;
    else
      itemHSize = minItemHSize + HPlusSize;
  }
  
  //repeat same story for vertical size
  int VMaxItems = contentsRect().height()  / (minItemVSize + totalSpacing);
  int VPlusSize = ( contentsRect().height() %
  (minItemVSize * VMaxItems) ) / VMaxItems;
  if (VPlusSize + minItemVSize > maxItemVSize)
    itemVSize = minItemVSize;
  else
    itemVSize = minItemVSize + VPlusSize;
  //next lines add widgets to layout
    // absolute position to set
    int x = 0;
    int y = 0;
    
    // count of horizontal added items,
    // increment it for each added item and
    // when it reachs HMaxItems set it and
    // x to zero
    int HCountItem = 0;
    QLayoutItem *item;
    foreach (item, itemsList) {
      item->setGeometry(QRect(QPoint(x,y),QPoint(itemHSize+x,itemVSize+y)));
      HCountItem++;
      if (HCountItem >= HMaxItems) {
	HCountItem = x = 0;
	y += itemVSize + spacing();
      }
      else
	x += itemHSize + spacing();
    }
开发者ID:clynamen,项目名称:QtClasses,代码行数:63,代码来源:MosaicLayout.cpp


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