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


C++ QPainter::drawPath方法代码示例

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


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

示例1: paintMeshElToBeHigh

void EditorArea::paintMeshElToBeHigh(QPainter &painter)
{
    qreal radius = size2screen(8);
    float fontSize = size2screen(12);

    qreal width = radius * 2;
    qreal height = radius * 2;

    QPainterPath path;
    QPainterPath text;
    QPainterPath circle;

    path.arcTo(QRectF(-radius, -radius, width, height), 0, 360);
    text.addText(-radius / 2.0, radius / 2.0, QFont("Arial", fontSize), meshElsType.value(meshElToBeHigh));
    circle.arcTo(QRectF(-radius * 3 / 2, -radius * 3 / 2, width * 3 / 2, height * 3 / 2), 0, 360);
    path.translate(meshElsPos.value(meshElToBeHigh));
    text.translate(meshElsPos.value(meshElToBeHigh));
    circle.translate(meshElsPos.value(meshElToBeHigh));

    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::magenta);
    painter.drawPath(circle);
    painter.setBrush(Qt::darkCyan);
    painter.drawPath(path);
    painter.setPen(Qt::yellow);
    painter.setBrush(Qt::yellow);
    painter.drawPath(text);
}
开发者ID:archTk,项目名称:arch-ne,代码行数:28,代码来源:editorarea.cpp

示例2: paintEvent

void Widget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter;
    QPainterPath path;
    QPen pen(Qt::darkGray);
    painter.begin(this);
    pen.setWidth(3);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);
    painter.setBrush(Qt::darkGray);
    painter.drawRect(ui->crossBlock->x(),ui->crossBlock->y(),ui->crossBlock->width(),ui->crossBlock->height());
    pen.setColor(Qt::black);
    painter.setPen(pen);
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+1,ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+ui->crossBlock->height());
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+ui->crossBlock->height(),ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+1);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    int mca_x = ui->mcaImage->x();
    int mca_y = ui->mcaImage->y();
    int mcb_x = ui->mcbImage->x();
    int mcb_y = ui->mcbImage->y();
    int mc_width = ui->mcaImage->width();
    int mc_height = ui->mcaImage->height();
    painter.setBrush(Qt::NoBrush);
//    painter.drawRoundedRect(mca_x,mca_y,mc_width,mc_height,5,5);
//    painter.drawRoundedRect(mcb_x,mcb_y,mc_width,mc_height,5,5);
    painter.drawRect(mca_x,mca_y,mc_width,mc_height);
    painter.drawRect(mcb_x,mcb_y,mc_width,mc_height);
//    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::NoBrush);
    painter.eraseRect(mca_x-5,mca_y-5,mc_width*0.1,mc_height*1.2);
    painter.eraseRect(mcb_x+mc_width*0.9+5,mcb_y-5,mc_width*0.1+2,mc_height*1.2);
    path.moveTo(mca_x+mc_width*0.1,mca_y);
    path.arcTo(QRectF(mca_x+mc_width*0.1-mc_height/2,mca_y,mc_height,mc_height),90,180);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    painter.drawPath(path);
    path.moveTo(mcb_x+mc_width*0.8,mcb_y);
    path.arcTo(QRectF(mcb_x+mc_width*0.9-mc_height/2,mcb_y,mc_height,mc_height),90,-180);
    painter.drawPath(path);
    int smallRectWidth =mc_width/6;
    int smallRectHeight= mc_height/4;
    painter.setBrush(Qt::yellow);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, str);
    painter.setPen(Qt::white);
    painter.drawText(QPointF(mca_x+mc_width/2-Size.width()/2,mca_y+mc_height/2+Size.height()/2),str);
    painter.drawText(QPointF(mcb_x+mc_width/2-Size.width()/2,mcb_y+mc_height/2+Size.height()/2),str);
    painter.end();

}
开发者ID:sobang2,项目名称:Qt,代码行数:59,代码来源:widget.cpp

示例3: doPaint

void Plotter::doPaint(QPainter &painter)
{
    QColor c1(127, 0, 0);
    QColor c2(0, 127, 0);
    QColor c3(0, 0, 127);
    QPen p(c1);
    p.setWidth(2);
    painter.setPen(p);

    QPainterPath path_sign;
    QPainterPath path_res;

    //////////////////////////////////
    door_.setMainData(E_, tlim_);
    //////////////////////////////////

    //for rand()
    QTime time = QTime::currentTime();
    qsrand((uint)time.msec());

    //for signal
    QPointF p_sign;
    float sig_end = 6*M_PI;
    float sig_count = width()/2;
    float sig_step = sig_end/sig_count;
    float count = 0;

    for (float i=sig_step; i<sig_end; i+=sig_step) {
        int k = randInt(noise_,-1*noise_);

        //drawing signal
        p_sign.setX(count++);
        p_sign.setY(MyFunc(i)+k);
        path_sign.lineTo(p_sign);

        door_.hadlePoint(p_sign);
        if (door_.storePointChanged()) {
            path_res.lineTo(door_.getLastStoredPoint());
            painter.drawPoint(door_.getLastStoredPoint());
        }
    }

    p.setColor(c2);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_sign);
    p.setColor(c3);
    p.setWidth(0.5);
    painter.setPen(p);
    painter.drawPath(path_res);
}
开发者ID:Andriks,项目名称:SwDoor,代码行数:51,代码来源:plotter.cpp

示例4: drawOutline

void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect)
{
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.resetTransform();
    painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
    painter.scale(rect.width()/2, rect.height()/2);
    painter.setPen(QPen(QBrush(Qt::gray), 0.005));
    
    if (getNumPieces() > 1) {
        for(int i=0; i<getNumRings(); ++i) {
            painter.resetTransform();
            painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
            painter.scale(rect.width()/2, rect.height()/2);
            painter.rotate(-m_colorRings[i].getShift().degrees());
            
            for(int j=0; j<m_colorRings[i].pieced.size(); ++j)
                painter.drawPath(m_colorRings[i].pieced[j]);
        }
        
        if (m_selectedRing >= 0 && m_selectedPiece >= 0) {
            painter.resetTransform();
            painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
            painter.rotate(-m_colorRings[m_selectedRing].getShift().degrees());
            painter.scale(rect.width()/2, rect.height()/2);
            
            painter.setPen(QPen(QBrush(Qt::red), 0.01));
            painter.drawPath(m_colorRings[m_selectedRing].pieced[m_selectedPiece]);
        }
    }
    else {
        for(int i=0; i<getNumRings(); ++i) {
            qreal rad = m_colorRings[i].outerRadius;
            painter.drawEllipse(QRectF(-rad, -rad, rad*2.0, rad*2.0));
        }
    }
    
    if (m_selectedRing >= 0) {
        qreal iRad = m_colorRings[m_selectedRing].innerRadius;
        qreal oRad = m_colorRings[m_selectedRing].outerRadius;
        
        painter.setPen(QPen(QBrush(Qt::red), 0.005));
        painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0));
        painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0));
        
        if (getNumPieces() <= 1) {
            float c = std::cos(-m_selectedColor.getH() * PI2);
            float s = std::sin(-m_selectedColor.getH() * PI2);
            painter.drawLine(QPointF(c*iRad, s*iRad), QPointF(c*oRad, s*oRad));
        }
    }
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:51,代码来源:kis_color_selector.cpp

示例5: paint

//! [paint function]
void DisplayWidget::paint(QPainter &painter)
{
//![paint picture]
    painter.setClipRect(QRect(0, 0, 200, 200));
    painter.setPen(Qt::NoPen);

    switch (background) {
    case Sky:
    default:
        painter.fillRect(QRect(0, 0, 200, 200), Qt::darkBlue);
        painter.translate(145, 10);
        painter.setBrush(Qt::white);
        painter.drawPath(moon);
        painter.translate(-145, -10);
        break;
    case Trees:
    {
        painter.fillRect(QRect(0, 0, 200, 200), Qt::darkGreen);
        painter.setBrush(Qt::green);
        painter.setPen(Qt::black);
        for (int y = -55, row = 0; y < 200; y += 50, ++row) {
            int xs;
            if (row == 2 || row == 3)
                xs = 150;
            else
                xs = 50;
            for (int x = 0; x < 200; x += xs) {
                painter.save();
                painter.translate(x, y);
                painter.drawPath(tree);
                painter.restore();
            }
        }
        break;
    }
    case Road:
        painter.fillRect(QRect(0, 0, 200, 200), Qt::gray);
        painter.setPen(QPen(Qt::white, 4, Qt::DashLine));
        painter.drawLine(QLine(0, 35, 200, 35));
        painter.drawLine(QLine(0, 165, 200, 165));
        break;
    }

    painter.setBrush(shapeColor);
    painter.setPen(Qt::black);
    painter.translate(100, 100);
    painter.drawPath(shapeMap[shape]);
//![paint picture]
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:50,代码来源:displaywidget.cpp

示例6: drawSavedContour

void ImageDisplayer::drawSavedContour(QPainter &painter) 
{
	//cout << "seeds size: " << seeds.size() << endl;
	//cout << "paths size: " << paths.size() << endl;
	if(seeds.size() ==  paths.size()) {
		for(int i=0; i<seeds.size(); i++) {
			// draw seed
			QBrush o = painter.brush();
			painter.setBrush(QColor(255, 0, 0, 255));
			int x = seeds[i].pos[0];
			int y = seeds[i].pos[1];
			int* tem = img2dis(x, y);
			painter.drawRect(tem[0]-3, tem[1]-3, 7, 7);
			painter.setBrush(o);

			// draw path
			QPainterPath path;
			vector<vec2i> p = paths[i];
			int* tem2 = img2dis(p[0].pos[0], p[0].pos[1]);
			path.moveTo(tem2[0], tem2[1]);
			for(int j=1; j<p.size(); j++) {
				tem2 = img2dis(p[j].pos[0], p[j].pos[1]);
				path.lineTo(tem2[0], tem2[1]);
			}
			QPen op = painter.pen();
			QPen pen(Qt::green, 3);
			painter.setPen(pen);
			painter.drawPath(path);
			painter.setPen(op);
		}
	}
}
开发者ID:GYingchao,项目名称:IntelligentScissor,代码行数:32,代码来源:imageDisplayer.cpp

示例7: DrawStaticLoading

void DrawStaticLoading(
		QPainter &p,
		QRectF rect,
		int stroke,
		QPen pen,
		QBrush brush) {
	PainterHighQualityEnabler hq(p);

	p.setBrush(brush);
	pen.setWidthF(stroke);
	pen.setCapStyle(Qt::RoundCap);
	pen.setJoinStyle(Qt::RoundJoin);
	p.setPen(pen);
	p.drawEllipse(rect);

	const auto center = rect.center();
	const auto first = QPointF(center.x(), rect.y() + 1.5 * stroke);
	const auto delta = center.y() - first.y();
	const auto second = QPointF(center.x() + delta * 2 / 3., center.y());
	if (delta > 0) {
		QPainterPath path;
		path.moveTo(first);
		path.lineTo(center);
		path.lineTo(second);
		p.drawPath(path);
	}
}
开发者ID:telegramdesktop,项目名称:tdesktop,代码行数:27,代码来源:animation.cpp

示例8: render

void QQuickShapeSoftwareRenderNode::render(const RenderState *state)
{
    if (m_sp.isEmpty())
        return;

    QSGRendererInterface *rif = m_item->window()->rendererInterface();
    QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));
    Q_ASSERT(p);

    const QRegion *clipRegion = state->clipRegion();
    if (clipRegion && !clipRegion->isEmpty())
        p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform

    p->setTransform(matrix()->toTransform());
    p->setOpacity(inheritedOpacity());

    for (const ShapePathRenderData &d : qAsConst(m_sp)) {
        if (d.hidden) {
            continue;
        }

//        QTransform oldTransform = p->transform();
//        p->setTransform(d.transform, true);

//        p->setOpacity(inheritedOpacity() * d.opacity);
        p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen);
        p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush);
        p->drawPath(d.path);

//        p->setTransform(oldTransform);
    }
}
开发者ID:Conntac,项目名称:lottie-qt,代码行数:32,代码来源:qquickshapesoftwarerenderer.cpp

示例9: DrawBoat

//-----------------------------------------------------------------------------
//! 
//-----------------------------------------------------------------------------
void tBoatWidget::DrawBoat( QPainter& painter )
{
    painter.save();

    // Draw boat
    QColor color;
    if( tSystemSettings::Instance()->NightMode() )
    {
        color = Qt::white;
        painter.setOpacity(0.2);
    }
    else
    {
        color = Qt::black;
        painter.setOpacity(0.5);
    }

    painter.setPen(QPen(color, 6, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin));
    painter.translate(QPointF((width()/2.0)+0.5, 15.0));
    QPainterPath p;

    p.moveTo( 28, 146 );
    p.cubicTo(  34, 90,  44, 70, 0, 0 );
    p.cubicTo( -44, 70, -34, 90, -28, 146 );
    p.lineTo( 28, 146 );

    painter.drawPath(p);

    painter.restore();
}
开发者ID:dulton,项目名称:53_hero,代码行数:33,代码来源:tBoatWidget.cpp

示例10: paintEvent

void Canvas::paintEvent(QPaintEvent *e)
{
    QPainter *p = new QPainter(this);
    QPen pen(QColor(0,0,0,255));

    if(p->isActive()){
        p->setRenderHint(QPainter::Antialiasing);
        pen.setWidth(1);
        p->setPen(pen);

        p->save();
        pen.setColor(QColor(255,0,0,255));
        p->setPen(pen);

        foreach(QPainterPath t, _ticks)
            p->drawPath(t);

        p->restore();

        p->drawEllipse(PADDING,PADDING,_radiusX*2,_radiusY*2);
        p->end();
    }

    QFrame::paintEvent(e);
}
开发者ID:ghetzel,项目名称:zee,代码行数:25,代码来源:dial.cpp

示例11: drawValue

void QRoundProgressBar::drawValue(QPainter &p, const QRectF &baseRect, double value, double arcLength)
{
    // nothing to draw
    if (value == m_min)
        return;

    // for Line style
    if (m_barStyle == StyleLine)
    {
        p.setPen(QPen(palette().highlight().color(), m_dataPenWidth));
        p.setBrush(Qt::NoBrush);
        p.drawArc(baseRect.adjusted(m_outlinePenWidth/2, m_outlinePenWidth/2, -m_outlinePenWidth/2, -m_outlinePenWidth/2),
                  m_nullPosition * 16,
                  -arcLength * 16);
        return;
    }

    // for Pie and Donut styles
    QPainterPath dataPath;
    dataPath.setFillRule(Qt::WindingFill);

    // pie segment outer
    dataPath.moveTo(baseRect.center());
    dataPath.arcTo(baseRect, m_nullPosition, -arcLength);
    dataPath.lineTo(baseRect.center());

    p.setBrush(palette().highlight());
    p.setPen(QPen(palette().shadow().color(), m_dataPenWidth));
    p.drawPath(dataPath);
}
开发者ID:Jinxiaohai,项目名称:QT,代码行数:30,代码来源:QRoundProgressBar.cpp

示例12: render

void TextRenderable::render(QPainter &painter, const RenderConfig &config) const
{
	painter.save();
	
	bool disable_antialiasing = config.options.testFlag(RenderConfig::Screen) && !(Settings::getInstance().getSettingCached(Settings::MapDisplay_TextAntialiasing).toBool());
	if (disable_antialiasing)
	{
		painter.setRenderHint(QPainter::Antialiasing, false);
		painter.setRenderHint(QPainter::TextAntialiasing, false);
	}
	
	if (framing_line)
	{
		QPen pen(painter.pen());
		pen.setJoinStyle(Qt::MiterJoin);
		pen.setMiterLimit(0.5);
		painter.setPen(pen);
	}
	
	painter.translate(anchor_x, anchor_y);
	if (rotation != 0)
		painter.rotate(-rotation * 180 / M_PI);
	painter.scale(scale_factor, scale_factor);
	painter.drawPath(path);
	
	painter.restore();
}
开发者ID:999999333,项目名称:mapper,代码行数:27,代码来源:renderable_implementation.cpp

示例13: drawOuterRing

void ColorWheel::drawOuterRing(QPainter &painter) {
    int r = qMin(this->width(), this->height());
    QPointF center(r/2.0, r/2.0);

    // paint hue wheel
    painter.save();
    QConicalGradient conicalGradient(center, 0);
    conicalGradient.setColorAt(0.0, Qt::red);
    conicalGradient.setColorAt(60.0/360.0, Qt::yellow);
    conicalGradient.setColorAt(120.0/360.0, Qt::green);
    conicalGradient.setColorAt(180.0/360.0, Qt::cyan);
    conicalGradient.setColorAt(240.0/360.0, Qt::blue);
    conicalGradient.setColorAt(300.0/360.0, Qt::magenta);
    conicalGradient.setColorAt(1.0, Qt::red);
    QBrush brush(conicalGradient);
    painter.setPen(Qt::NoPen);
    painter.setBrush(brush);

    // outer circle
    QPainterPath path;
    path.addEllipse(center, r/2.0 - margin_, r/2.0 - margin_);
    // inner circle
    path.addEllipse(center, r/2.0 - margin_ - wheelWidth_, r/2.0 - margin_ - wheelWidth_);
    painter.drawPath(path);
    painter.restore();
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:26,代码来源:colorwheel.cpp

示例14: render

    void GraphPathRenderer::render(QImage *image, QRectF clip, 
            QTransform &t)
    {
        //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__);

        QPainter p(image);
        p.setTransform(t);
        //p.setClipRect(QRect(0, 0, image->width(), image->height())); //显示的图形会有空白的clip 矩形

        QPainter *d = &p;

        //d->setRenderHint(QPainter::Antialiasing, true);
        //d->setRenderHint(QPainter::TextAntialiasing, true);

        QVector<struct GraphPathRenderer::shape>::const_iterator it;
        for (it = m_data->paths.begin(); it != m_data->paths.end(); 
                ++it) {
            d->save();
            const struct GraphPathRenderer::shape &item = *it;
            d->setPen(item.pen);
            d->setBrush(item.brush);
            d->drawPath(item.path);
            d->restore();
        }
    }
开发者ID:ongbe,项目名称:xchart,代码行数:25,代码来源:graph_path_renderer.cpp

示例15:

		/// Draw.
		void Shape2DFree::drawShape(QPainter& painter) const
		{
			QPainterPath path;
			path.addPolygon(m_polygon);
			painter.fillPath(path, m_fill_color);
			painter.drawPath(m_outline);
		}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:8,代码来源:Shape2D.cpp


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