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


C++ QRectF::setRect方法代码示例

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


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

示例1: boundingRect

// Forme englobante
QRectF Mur::boundingRect() const
{
    QRectF boite;

    switch(mur_)
    {
        case 0 :
            boite.setRect(scene()->width() - 50, 50, 1, scene()->height() - 100);
            break;

        case 1 :
            boite.setRect(50, scene()->height() - 50, scene()->width() - 100, 1);
            break;

        case 2 :
            boite.setRect(50, 50, 1, scene()->height() - 100);
            break;

        case 3 :
            boite.setRect(50, 50, scene()->width() - 100, 1);
            break;
    }

    return boite;
}
开发者ID:SebLediacre,项目名称:Projet_SMA,代码行数:26,代码来源:Mur.cpp

示例2: scaleView

void ZoomTool::scaleView(const QPointF &centerPos)
{

    QTransform transform;
    transform.scale(m_currentScale, m_currentScale);
    view()->setTransform(transform);

    QPointF adjustedCenterPos = centerPos;
    QSize rectSize(view()->rect().width() / m_currentScale,
                   view()->rect().height() / m_currentScale);

    QRectF sceneRect;
    if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) {
        adjustedCenterPos.rx() = rectSize.width() / 2;
        adjustedCenterPos.ry() = rectSize.height() / 2;
    }

    if (m_currentScale < 1.0f) {
        adjustedCenterPos.rx() = rectSize.width() / 2;
        adjustedCenterPos.ry() = rectSize.height() / 2;
        sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
                          view()->rect().height() / 2 -rectSize.height() / 2,
                          rectSize.width(),
                          rectSize.height());
    } else {
        sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
                          adjustedCenterPos.y() - rectSize.height() / 2,
                          rectSize.width(),
                          rectSize.height());
    }

    view()->setSceneRect(sceneRect);
}
开发者ID:RS102839,项目名称:qt,代码行数:33,代码来源:zoomtool.cpp

示例3: boundingRect

/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotMultiBarChart::boundingRect() const
{
    const size_t numSamples = dataSize();

    if ( numSamples == 0 )
        return QwtPlotSeriesItem::boundingRect();

    const double baseLine = baseline();

    QRectF rect;

    if ( d_data->style != QwtPlotMultiBarChart::Stacked )
    {
        rect = QwtPlotSeriesItem::boundingRect();

        if ( rect.height() >= 0 )
        {
            if ( rect.bottom() < baseLine )
                rect.setBottom( baseLine );
            if ( rect.top() > baseLine )
                rect.setTop( baseLine );
        }
    }
    else
    {
        double xMin, xMax, yMin, yMax;

        xMin = xMax = 0.0;
        yMin = yMax = baseLine;

        const QwtSeriesData<QwtSetSample> *series = data();

        for ( size_t i = 0; i < numSamples; i++ )
        {
            const QwtSetSample sample = series->sample( i );
            if ( i == 0 )
            {
                xMin = xMax = sample.value;
            }
            else
            {
                xMin = qMin( xMin, sample.value );
                xMax = qMax( xMax, sample.value );
            }

            const double y = baseLine + sample.added();

            yMin = qMin( yMin, y );
            yMax = qMax( yMax, y );
        }
        rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin );
    }

    if ( orientation() == Qt::Horizontal )
        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );

    return rect;
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:62,代码来源:qwt_plot_multi_barchart.cpp

示例4: paintEvent

void SSlider::paintEvent(QPaintEvent*) {

	// This whole function is suboptimal
	QPainter painter(this);

	painter.setRenderHints(QPainter::Antialiasing);

	auto widthActual = ((width()-20-30)/maximum())*maximum();
	mWidthActual = widthActual;
	auto xActual = 10+(width()-20-widthActual)/2;
	mXActual = xActual;
	auto jump = widthActual/maximum();
	mJump = jump;

	auto xpos = (jump*value())+xActual;
	cursor = new QRectF(xpos,0,mControlSize,mControlSize);
	QRectF pilot(xActual,0, widthActual+mControlSize, mControlSize);
	painter.setPen(QPen(QColor("#161616")));
	painter.setBrush(QBrush(QColor("#240128")));
	painter.drawRoundedRect(pilot, mHalfWidth,mHalfWidth);
	QRectF highlight;

	auto startX = mStart*mJump+mXActual;
	if(xpos == startX) {
		highlight.setRect(0,0,0,0);
	} else if(xpos > startX) {
		highlight.setRect(startX,0, xpos+mControlSize-startX, mControlSize);
	} else {
		highlight.setRect(xpos,0, startX-(xpos)+mControlSize, mControlSize);
	}

	painter.setBrush(QBrush(QColor("#6E047C")));

	QLinearGradient gradient;
	gradient.setStart(highlight.width() / 2, 0);
	gradient.setFinalStop(highlight.width() / 2, highlight.height());

	gradient.setColorAt(0, "#B64FC4");
	gradient.setColorAt(1, "#6E047C");
	painter.setBrush(QBrush(gradient));
	painter.drawRoundedRect(highlight, mHalfWidth,mHalfWidth);

	if(mGrabbed) {
		painter.setBrush(QBrush(QColor("#D24CE3")));
	} else {
		painter.setBrush(QBrush(QColor("#8E06A0")));
	}

	painter.setPen(QPen(QColor("#52015B")));
	painter.drawEllipse(*cursor);
	painter.setPen(QPen(QColor("#B1B7E6")));
}
开发者ID:carrotsrc,项目名称:strangepad,代码行数:52,代码来源:SSlider.cpp

示例5: be

/*!
  \brief Render the plot to a QSvgGenerator

  If the generator has a view box, the plot will be rendered into it.
  If it has no viewBox but a valid size the target coordinates
  will be (0, 0, generator.width(), generator.height()). Otherwise
  the target rectangle will be QRectF(0, 0, 800, 600);

  \param plot Plot to be rendered
  \param generator SVG generator
*/
void QwtPolarRenderer::renderTo(
    QwtPolarPlot *plot, QSvgGenerator &generator ) const
{
    QRectF rect = generator.viewBoxF();
    if ( rect.isEmpty() )
        rect.setRect( 0, 0, generator.width(), generator.height() );

    if ( rect.isEmpty() )
        rect.setRect( 0, 0, 800, 600 ); // something

    QPainter p( &generator );
    render( plot, &p, rect );
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:24,代码来源:qwt_polar_renderer.cpp

示例6: boundingRect

/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotIntervalCurve::boundingRect() const
{
    QRectF rect = QwtPlotSeriesItem<QwtIntervalSample>::boundingRect();
    if ( rect.isValid() && orientation() == Qt::Vertical )
        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );

    return rect;
}
开发者ID:1heinz,项目名称:TauLabs,代码行数:12,代码来源:qwt_plot_intervalcurve.cpp

示例7: boundingRect

/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotTradingCurve::boundingRect() const
{
    QRectF rect = QwtPlotSeriesItem::boundingRect();
    if ( orientation() == Qt::Vertical )
        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );

    return rect;
}
开发者ID:svn2github,项目名称:Qwt_trunk,代码行数:12,代码来源:qwt_plot_tradingcurve.cpp

示例8: bbox

QRectF PositionCursor::bbox() const
      {
      QRectF r;
      qreal h = _sv->score()->spatium() * 2;

      switch(_type) {
            case CursorType::LOOP_IN:
                  r.setRect(_rect.x(), _rect.y(), h, _rect.height());
                  break;
            case CursorType::LOOP_OUT:
                  r.setRect(_rect.x() - h, _rect.y(), h, _rect.height());
                  break;
            default:
                  r = _rect;
                  break;
            }
      return r.adjusted(-2, -2, 2, 2);
      }
开发者ID:riban-bw,项目名称:MuseScore,代码行数:18,代码来源:textcursor.cpp

示例9: relativeResizeRect

void QgsComposerUtils::relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter )
{
  //linearly scale rectToResize relative to the scaling from boundsBefore to boundsAfter
  double left = relativePosition( rectToResize.left(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
  double right = relativePosition( rectToResize.right(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
  double top = relativePosition( rectToResize.top(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
  double bottom = relativePosition( rectToResize.bottom(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );

  rectToResize.setRect( left, top, right - left, bottom - top );
}
开发者ID:dakcarto,项目名称:QGIS,代码行数:10,代码来源:qgscomposerutils.cpp

示例10: getHandleRect

/***********************************************************************
 *Funtion : Get the handle rect
 *Return  : QRectF handle rect.
 *Parameter: handle id.
 **********************************************************************/
QRectF SamDrawItemBase::getHandleRect(int iHandleID, QRectF &qrcBondingRect)
{
    QRectF qrRect;
    // get the center of the handle in logical coords
    QPointF qpPoint = getHandle(iHandleID, qrcBondingRect);

    /*Set the rect and normalize it*/
    qrRect.setRect(qpPoint.rx()-SAMDRAW_TRACKER_POS_OFT, qpPoint.ry()-SAMDRAW_TRACKER_POS_OFT, SAMDRAW_TRACKER_SIZE, SAMDRAW_TRACKER_SIZE);
    qrRect = qrRect.normalized();

    return qrRect;
}
开发者ID:maqiangddb,项目名称:pc_code,代码行数:17,代码来源:samdrawitembase.cpp

示例11: drawBackground

void KBBLevelConfigurationPreview::drawBackground(QPainter* painter, const QRectF&)
{
	QRectF rectBackground;

	// TODO: This is duplication of code from the class KBBScalableGraphicWidget. Try to fix this.
	const qreal sW = scene()->width();
	const qreal sH = scene()->height();
	const qreal wW = width();
	const qreal wH = height();
	const qreal offset = (sH+sW)/100 ;
	if (sH*wW > sW*wH) {
		// The widget is larger than the scene
		qreal w =  wW*sH/wH;
		rectBackground.setRect((sW-w)/2-offset, -offset, w + 2*offset, sH + 2*offset);
	} else {
		// The scene is larger than the widget (or as large)
		qreal h =  wH*sW/wW;
		rectBackground.setRect(-offset, (sH-h)/2-offset, sW + 2*offset, h + 2*offset);
	}

	m_themeManager->svgRenderer()->render(painter, m_themeManager->elementId(KBBScalableGraphicWidget::background), rectBackground);
}
开发者ID:jsj2008,项目名称:kdegames,代码行数:22,代码来源:kbblevelconfigurationpreview.cpp

示例12: paint

void GraphNode::paint(QPainter *painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
{
    QPen pen(Qt::black, 2);
    QBrush brush(Qt::red);
    painter->setPen(pen);
    painter->setBrush(brush);
    painter->drawEllipse(rect());
    painter->drawText(rect(), Qt::AlignCenter, label);

    if (!subscript.isEmpty()) {
        QRectF subRect;
        subRect.setRect(cx - 1.65*r, cy + 1.15*r, 15, 15);
        painter->drawText(subRect, Qt::AlignCenter, subscript);
        scene()->update(subRect);
    }
}
开发者ID:zdonato,项目名称:GraphGUI,代码行数:16,代码来源:graphnode.cpp

示例13: loadOdfViewbox

QRectF KPathShape::loadOdfViewbox(const KXmlElement & element) const
{
    QRectF viewbox;

    QString data = element.attributeNS(KOdfXmlNS::svg, "viewBox");
    if (! data.isEmpty()) {
        data.replace(',', ' ');
        QStringList coordinates = data.simplified().split(' ', QString::SkipEmptyParts);
        if (coordinates.count() == 4) {
            viewbox.setRect(coordinates[0].toDouble(), coordinates[1].toDouble(),
                            coordinates[2].toDouble(), coordinates[3].toDouble());
        }
    }

    return viewbox;
}
开发者ID:KDE,项目名称:koffice,代码行数:16,代码来源:KPathShape.cpp

示例14: boundingRect

/*!
  \return Bounding rectangle of all samples.
  For an empty series the rectangle is invalid.
*/
QRectF QwtPlotBarChart::boundingRect() const
{
    const size_t numSamples = dataSize();
    if ( numSamples == 0 )
        return QwtPlotSeriesItem::boundingRect();

    const double baseLine = baseline();

    QRectF rect = QwtPlotSeriesItem::boundingRect();
    if ( rect.bottom() < baseLine )
        rect.setBottom( baseLine );
    if ( rect.top() > baseLine )
        rect.setTop( baseLine );

    if ( rect.isValid() && ( orientation() == Qt::Horizontal ) )
        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );

    return rect;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:23,代码来源:qwt_plot_barchart.cpp

示例15: mouseMoveEvent

void Note::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
	if (m_spaceBarWasPressed) {
		event->ignore();
		return;
	}

	if (m_inResize) {
		double minWidth = emptyMinWidth;
		double minHeight = emptyMinHeight;
		QSizeF gripSize = m_resizeGrip->boundingRect().size();
		QSizeF minSize = m_graphicsTextItem->document()->size() + gripSize + gripSize;
		if (minSize.height() > minHeight) minHeight = minSize.height();

		QRectF rect = boundingRect();
		rect.moveTopLeft(this->pos());

		double oldX1 = rect.x();
		double oldY1 = rect.y();
		double newX = event->scenePos().x() + m_inResize->resizeOffset().x();
		double newY = event->scenePos().y() + m_inResize->resizeOffset().y();
		QRectF newR;

		if (newX - oldX1 < minWidth) {
			newX = oldX1 + minWidth;
		}
		if (newY - oldY1 < minHeight) {
			newY = oldY1 + minHeight;
		}	
		newR.setRect(0, 0, newX - oldX1, newY - oldY1);

		prepareGeometryChange();
		m_rect = newR;
		positionGrip();
		event->accept();
		
		return;
	}

	ItemBase::mouseMoveEvent(event);
}
开发者ID:bacchante95,项目名称:fritzing,代码行数:40,代码来源:note.cpp


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