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


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

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


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

示例1: switch

QPainterPath
Shapes::stick(const QRectF &bound, Style style)
{
    _S(6)
    QPainterPath path;
    switch (style)
    {
    case Square:
        path.addRect(bound.adjusted(s6, s6, -s6, -s6));
        break;
    case LasseKongo:
    {
        _S(4);
        const float d = 3*s4;
        QRectF rect = bound.adjusted(0,0,-d,-d);
        path.addRect(rect);
        path.addRect(rect.translated(d,0));
        path.addRect(rect.translated(0,d));
        path.addRect(rect.translated(d,d));
        break;
    }
    default:
    case Round:
    case TheRob:
        path.addEllipse(bound.adjusted(s6, s6, -s6, -s6));
        break;
    }
    return path;
}
开发者ID:thibautquentinjacob,项目名称:BespinMod,代码行数:29,代码来源:shapes.cpp

示例2: drawText

void GraphicsDImgView::drawText(QPainter* p, const QRectF& rect, const QString& text)
{
    p->save();

    p->setRenderHint(QPainter::Antialiasing, true);
    p->setBackgroundMode(Qt::TransparentMode);

    // increase width by 5 and height by 2
    QRectF textRect    = rect.adjusted(0, 0, 5, 2);

    // Draw background
    p->setPen(Qt::black);
    QColor semiTransBg = palette().color(QPalette::Window);
    semiTransBg.setAlpha(190);
    p->setBrush(semiTransBg);
    //p->translate(0.5, 0.5);
    p->drawRoundRect(textRect, 10.0, 10.0);

    // Draw shadow and text
    p->setPen(palette().color(QPalette::Window).dark(115));
    p->drawText(textRect.translated(3, 1), text);
    p->setPen(palette().color(QPalette::WindowText));
    p->drawText(textRect.translated(2, 0), text);

    p->restore();
}
开发者ID:KDE,项目名称:digikam,代码行数:26,代码来源:graphicsdimgview.cpp

示例3: paint

void WeatherWallpaper::paint(QPainter * painter, const QRectF & exposedRect)
{
    // Check if geometry changed
    if (m_size != boundingRect().size().toSize()) {
        calculateGeometry();
        if (!m_size.isEmpty() && !m_img.isEmpty()) { // We have previous image
            renderWallpaper();
            return;
        }
    }

    if (m_pixmap.isNull()) {
        painter->fillRect(exposedRect, QBrush(m_color));
        return;
    }

    if (painter->worldMatrix() == QMatrix()) {
        // draw the background untransformed when possible;(saves lots of per-pixel-math)
        painter->resetTransform();
    }

    // blit the background (saves all the per-pixel-products that blending does)
    painter->setCompositionMode(QPainter::CompositionMode_Source);

    // for pixmaps we draw only the exposed part (untransformed since the
    // bitmapBackground already has the size of the viewport)
    painter->drawPixmap(exposedRect, m_pixmap, exposedRect.translated(-boundingRect().topLeft()));

    if (!m_oldFadedPixmap.isNull()) {
        // Put old faded image on top.
        painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
        painter->drawPixmap(exposedRect, m_oldFadedPixmap,
                            exposedRect.translated(-boundingRect().topLeft()));
    }
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:35,代码来源:weatherwallpaper.cpp

示例4: resize

void ResizeCommand::resize(NodeElement * const element, const QRectF &geometry)
{
	if (element && geometryOf(element) != geometry) {
		ResizeHandler handler(element);
		handler.resize(geometry.translated(-geometry.topLeft()), geometry.topLeft(), false);
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:7,代码来源:resizeCommand.cpp

示例5: rotatedRect

QRectF rotatedRect( const QRectF& oldRect, qreal angleInt, const QPointF& center )
{
    const QRect rect( oldRect.translated( center ).toRect() );
    const qreal angle = PI * angleInt / 180.0;
    const qreal cosAngle = cos( angle );
    const qreal sinAngle = sin( angle );
    QMatrix rotationMatrix(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0);
    QPolygon rotPts;
    rotPts <<  rotationMatrix.map(rect.topLeft()) //QPoint(0,0)
            << rotationMatrix.map(rect.topRight())
            << rotationMatrix.map(rect.bottomRight())
            << rotationMatrix.map(rect.bottomLeft());
            //<< rotatedPoint(rect.topRight(), angleInt, center).toPoint()
            //<< rotatedPoint(rect.bottomRight(), angleInt, center).toPoint()
            //<< rotatedPoint(rect.bottomLeft(), angleInt, center).toPoint();
    return rotPts.boundingRect();
/*
    const QPointF topLeft( rotatedPoint( oldRect.topLeft(), angle, center ) );
    const QPointF topRight( rotatedPoint( oldRect.topRight(), angle, center ) );
    const QPointF bottomLeft( rotatedPoint( oldRect.bottomLeft(), angle, center ) );
    const QPointF bottomRight( rotatedPoint( oldRect.bottomRight(), angle, center ) );

    const qreal x = qMin( qMin( topLeft.x(), topRight.x() ), qMin( bottomLeft.x(), topLeft.x() ) );
    const qreal y = qMin( qMin( topLeft.y(), topRight.y() ), qMin( bottomLeft.y(), topLeft.y() ) );
    const qreal width = qMax( qMax( topLeft.x(), topRight.x() ), qMax( bottomLeft.x(), topLeft.x() ) ) - x;
    const qreal height = qMax( qMax( topLeft.y(), topRight.y() ), qMax( bottomLeft.y(), topLeft.y() ) ) - y;

    return QRectF( x, y, width, height );
*/
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:30,代码来源:KDChartLayoutItems.cpp

示例6: calculateTextRect

QRectF PheromoneItem::calculateTextRect(const QString &str, const QFont &font, const QRectF &referencia)
{
//    QFont font("arial", 7);
    QFontMetricsF txtMetrics(font);
    QRectF tmpRect = txtMetrics.boundingRect(str);
    return tmpRect.translated(-tmpRect.width()/2, referencia.y() - tmpRect.height());
}
开发者ID:marlncpe,项目名称:INSYDE,代码行数:7,代码来源:pheromoneitem.cpp

示例7: printColorSensor

QImage TwoDModelEngineApi::printColorSensor(PortInfo const &port) const
{
	if (mModel.robotModel().configuration().type(port).isNull()) {
		return QImage();
	}

	QPair<QPointF, qreal> const neededPosDir = countPositionAndDirection(port);
	QPointF const position = neededPosDir.first;
	qreal const width = sensorWidth / 2.0;
	QRectF const scanningRect = QRectF(position.x() - width, position.y() - width, 2 * width, 2 * width);

	QImage image(scanningRect.size().toSize(), QImage::Format_RGB32);
	QPainter painter(&image);

	QBrush brush(Qt::SolidPattern);
	brush.setColor(Qt::white);
	painter.setBrush(brush);
	painter.setPen(QPen(Qt::white));
	painter.drawRect(scanningRect.translated(-scanningRect.topLeft()));

	bool const wasSelected = mView.sensorItem(port)->isSelected();
	mView.setSensorVisible(port, false);
	mView.scene()->render(&painter, QRectF(), scanningRect);
	mView.setSensorVisible(port, true);
	mView.sensorItem(port)->setSelected(wasSelected);

	return image;
}
开发者ID:ASabina,项目名称:qreal,代码行数:28,代码来源:twoDModelEngineApi.cpp

示例8: boundingRectFor

QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const
{
    qreal padding = m_blurRadius * 2;
    return rect.united(
        rect.translated(m_xOffset, m_yOffset)
        .adjusted(-padding, -padding, padding, padding)
        );
}
开发者ID:KDE,项目名称:homerun,代码行数:8,代码来源:shadoweffect.cpp

示例9: paint

void EditorMagnifierItem::paint(QPainter *                      painter,
                                const QStyleOptionGraphicsItem *option,
                                QWidget *                       widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    if ( !scene() )
        return;

    QRectF rect = getRect();

    EditorScene *scn = qobject_cast<EditorScene *>( scene() );
    if (rect.isValid() && m_valid && scn)
    {
        updateMask();
        painter->save(); // because clipping is active !!

        QPainterPath clipPath;
        clipPath.addEllipse(getRect().center(), getRect().width() / 2,getRect().width() / 2);
        painter->setClipPath(clipPath);
        painter->setClipping(true);

        // TODO add extracted image to a cache !!!
        QRectF extractRect( rect.translated( pos() - scn->getUnderlayOffset() ) );
        int extractWidth = extractRect.width() / m_magnifyingFactor;
        extractRect.adjust(extractWidth,extractWidth,-extractWidth,-extractWidth);

        QRectF bgRect = scn->getUnderlayImage().rect();

        QRectF croppedRect = extractRect.intersected(bgRect);
        if ( !croppedRect.isNull() )
        {
            QImage background = scn->getUnderlayImage().copy( croppedRect.toRect() );
            QImage mag = background.scaled(rect.size().toSize(),Qt::KeepAspectRatio,Qt::SmoothTransformation);
            painter->drawImage(rect,mag);
        }

        painter->drawPixmap(rect.topLeft(), m_imgMask);
        painter->restore();
    }

    // draw a box if selected
    if( isSelected() )
    {
        painter->save();

        QPen pen;
        pen.setCosmetic(true);
        pen.setColor(Qt::black);
        pen.setWidth(1);
        pen.setStyle(Qt::DotLine);
        painter->setPen(pen);
        painter->drawRect(rect);
        painter->restore();
    }
}
开发者ID:shinsterneck,项目名称:hotshots,代码行数:57,代码来源:EditorMagnifierItem.cpp

示例10: CenterRectSlaveFromMaster

QRectF CenterRectSlaveFromMaster( const QRectF Master ,
                                               QRectF Slave  )
{
  QRectF SlaveOnline = Slave.translated(Master.center());
  const qreal wi = Slave.width() / 2;
  const qreal hi = Slave.height() / 2;
  SlaveOnline.translate( 0 - wi , 0 - hi ); 
  return SlaveOnline;
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:9,代码来源:scribemime.cpp

示例11: contentsRect

QRectF CDiagramTextNode::contentsRect() const
{
	QRectF		r;

	r = CDiagramNode::contentsRect();
	if (m_coordMode != CDiagramItem::CenterAsOrigin)
		r = r.translated( -r.topLeft() );
	return r;
}
开发者ID:jetcodes,项目名称:JetMind,代码行数:9,代码来源:CDiagramTextNode.cpp

示例12: paint

void ChannelGraphItem::paint(QPainter* painter, QColor color)
{
	QRectF rect = boundingRect();
	QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
	gradient.setColorAt(0, QColor(255, 255, 255));
	gradient.setColorAt(1, color);
	painter->setBrush(gradient);
	painter->drawRoundedRect(rect, margin, margin);
	painter->drawText(rect.translated(1, -1), Qt::AlignCenter, name);
}
开发者ID:Noiled,项目名称:equalizerapo,代码行数:10,代码来源:ChannelGraphItem.cpp

示例13: paintOutlineRect

QRectF KisExperimentPaintOpSettings::paintOutlineRect(const QPointF& pos, KisImageWSP image, OutlineMode _mode) const
{
    if (_mode != CursorIsOutline) return QRectF();
    qreal width = getInt(EXPERIMENT_START_SIZE); /* scale();*/
    qreal height = getInt(EXPERIMENT_START_SIZE); /* scale();*/
    width += 10;
    height += 10;
    QRectF rc = QRectF(0, 0, width, height);
    return image->pixelToDocument(rc.translated(- QPoint(width * 0.5, height * 0.5))).translated(pos);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:10,代码来源:kis_experiment_paintop_settings.cpp

示例14:

void D2ModelScene::centerOnRobot()
{
	for (QGraphicsView * const view : views()) {
		QRectF const viewPortRect = view->mapToScene(view->viewport()->rect()).boundingRect();
		if (!viewPortRect.contains(mRobot->sceneBoundingRect().toRect())) {
			QRectF const requiredViewPort = viewPortRect.translated(mRobot->scenePos() - viewPortRect.center());
			setSceneRect(itemsBoundingRect().united(requiredViewPort));
			view->centerOn(mRobot);
		}
	}
}
开发者ID:Anna-,项目名称:qreal,代码行数:11,代码来源:d2ModelScene.cpp

示例15: setGeometry

void NodeElement::setGeometry(const QRectF &geom)
{
	prepareGeometryChange();
	setPos(geom.topLeft());
	if (geom.isValid()) {
		mContents = geom.translated(-geom.topLeft());
	}
	mTransform.reset();
	mTransform.scale(mContents.width(), mContents.height());
	adjustLinks();
}
开发者ID:Antropovi,项目名称:qreal,代码行数:11,代码来源:nodeElement.cpp


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