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


C++ QPainterPath函数代码示例

本文整理汇总了C++中QPainterPath函数的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath函数的具体用法?C++ QPainterPath怎么用?C++ QPainterPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: spatium

void Spacer::layout0()
      {
      qreal _spatium = spatium();

      path    = QPainterPath();
      qreal w = _spatium;
      qreal b = w * .5;
      qreal h = _gap;

      switch (spacerType()) {
            case SpacerType::DOWN:
                  path.lineTo(w, 0.0);
                  path.moveTo(b, 0.0);
                  path.lineTo(b, h);
                  path.lineTo(0.0, h-b);
                  path.moveTo(b, h);
                  path.lineTo(w, h-b);
                  break;
            case SpacerType::UP:
                  path.moveTo(b, 0.0);
                  path.lineTo(0.0, b);
                  path.moveTo(b, 0.0);
                  path.lineTo(w, b);
                  path.moveTo(b, 0.0);
                  path.lineTo(b, h);
                  path.moveTo(0.0, h);
                  path.lineTo(w, h);
                  break;
            case SpacerType::FIXED:
                  path.lineTo(w, 0.0);
                  path.moveTo(b, 0.0);
                  path.lineTo(b, h);
                  path.moveTo(0.0, h);
                  path.lineTo(w, h);
                  break;
            }
      qreal lw = _spatium * 0.4;
      QRectF bb(0, 0, w, h);
      bb.adjust(-lw, -lw, lw, lw);
      setbbox(bb);
      }
开发者ID:CammyVee,项目名称:MuseScore,代码行数:41,代码来源:spacer.cpp

示例2: shape

QPainterPath ArrowItem::shape() const
{
    QPainterPath path;
    path.setFillRule(Qt::WindingFill);
    if (m_shaftItem &&m_shaftItem->path() != QPainterPath()) {
        QPainterPathStroker ps;
        QPen pen = m_shaftItem->pen();
        ps.setCapStyle(pen.capStyle());
        ps.setJoinStyle(pen.joinStyle());
        ps.setMiterLimit(pen.miterLimit());
        // overwrite pen width to make selection more lazy
        ps.setWidth(16.0);
        QPainterPath p = ps.createStroke(m_shaftItem->path());
        path.addPath(p);
    }
    if (m_startHeadItem)
        path.addRect(mapRectFromItem(m_startHeadItem, m_startHeadItem->boundingRect()));
    if (m_endHeadItem)
        path.addRect(mapRectFromItem(m_endHeadItem, m_endHeadItem->boundingRect()));
    return path;
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:21,代码来源:arrowitem.cpp

示例3: qreal

QPainterPath Toolbox::shapeFromPath(const QPainterPath& path, const QPen& pen,
                                    const QBrush&         brush,
                                    const UnsignedLength& minWidth) noexcept {
  // http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/graphicsview/qgraphicsitem.cpp
  // Function: qt_graphicsItem_shapeFromPath()

  if (path == QPainterPath() || pen == Qt::NoPen) {
    return path;
  } else {
    QPainterPathStroker ps;
    ps.setCapStyle(pen.capStyle());
    ps.setWidth(qMax(qMax(pen.widthF(), qreal(0.00000001)), minWidth->toPx()));
    ps.setJoinStyle(pen.joinStyle());
    ps.setMiterLimit(pen.miterLimit());
    QPainterPath p = ps.createStroke(path);
    if (brush != Qt::NoBrush) {
      p.addPath(path);
    }
    return p;
  }
}
开发者ID:LibrePCB,项目名称:LibrePCB,代码行数:21,代码来源:toolbox.cpp

示例4: recreatePolygon

QPolygon RescaleWidget::
        recreatePolygon ()
{
    QPoint o = rect().center();
    QPoint x = scalex_ * (rect().topRight() - rect().topLeft())/4;
    QPoint y = scaley_ * (rect().bottomLeft() - rect().topLeft())/4;

    QPolygon poly;
    float d = 0.3;
    float r = 0.1;
    poly.push_back( o - r*x - r*y);
    poly.push_back( o - d*x - y);
    poly.push_back( o + d*x - y);
    poly.push_back( o + r*x - r*y);
    poly.push_back( o - d*y + x);
    poly.push_back( o + d*y + x);
    poly.push_back( o + r*x + r*y);
    poly.push_back( o + d*x + y);
    poly.push_back( o - d*x + y);
    poly.push_back( o - r*x + r*y);
    poly.push_back( o + d*y - x);
    poly.push_back( o - d*y - x);

    if ( 0 == "push a circle" )
    {
        float N = max(width(), height());
        for (float i=0; i<N; ++i)
        {
            float a = 2*M_PI*(i/N);
            poly.push_back(o + x*cos(a) + y*sin(a));
        }
    }

    path_ = QPainterPath();
    path_.addPolygon(poly);

    update();

    return poly;
}
开发者ID:davidhesselbom,项目名称:freq,代码行数:40,代码来源:rescalewidget.cpp

示例5: prepareGeometryChange

void UserMarkerItem::updateFullText()
{
	prepareGeometryChange();

	if(_text2.isEmpty() || !m_showSubtext)
		_fulltext = _text1;
	else
		_fulltext = _text1 + "\n[" + _text2 + ']';

	// Make a new bubble for the text
	QRect textrect = qApp->fontMetrics().boundingRect(QRect(0, 0, 0xffff, 0xffff), 0, _fulltext);

	const float round = 3;
	const float padding = 5;
	const float width = qMax((ARROW+round)*2, textrect.width() + 2*padding);
	const float rad = width / 2.0;
	const float height = textrect.height() + ARROW + 2 * padding;

	_bounds = QRectF(-rad, -height, width, height);

	_textrect = _bounds.adjusted(padding, padding, -padding, -padding);

	_bubble = QPainterPath(QPointF(0, 0));

	_bubble.lineTo(-ARROW, -ARROW);
	_bubble.lineTo(-rad+round, -ARROW);

	_bubble.quadTo(-rad, -ARROW, -rad, -ARROW-round);
	_bubble.lineTo(-rad, -height+round);
	_bubble.quadTo(-rad, -height, -rad+round, -height);

	_bubble.lineTo(rad-round, -height);
	_bubble.quadTo(rad, -height, rad, -height+round);
	_bubble.lineTo(rad, -ARROW-round);

	_bubble.quadTo(rad, -ARROW, rad-round, -ARROW);
	_bubble.lineTo(ARROW, -ARROW);

	_bubble.closeSubpath();
}
开发者ID:Rambo2015,项目名称:Drawpile,代码行数:40,代码来源:usermarkeritem.cpp

示例6: QPainterPath

void ER_ItemRelationship::adjustNameSize()
{
	defaultLength = WIDTH_LENGTH;
	dynamicLength = componentName.length() * WORD_LENGTH; // 依name大小調整邊框寬度
	pointVector.clear();
	pointVector.push_back(QPointF(defaultLength + dynamicLength, 0));
	pointVector.push_back(QPointF(0, -defaultLength));
	pointVector.push_back(QPointF(-(defaultLength + dynamicLength), 0));
	pointVector.push_back(QPointF(0, defaultLength));
	pointVector.push_back(QPointF(defaultLength + dynamicLength, 0));
	
	componentPainterPath = QPainterPath();
	componentPainterPath.addPolygon(QPolygonF(pointVector));
	componentPen.setColor(Qt::black);
	componentPen.setWidth(PEN_WIDTH);

	originalConnectionPoint.clear();
	originalConnectionPoint.push_back(QPointF(0, defaultLength - FOUR));
	originalConnectionPoint.push_back(QPointF(defaultLength + dynamicLength - FOUR, 0));
	originalConnectionPoint.push_back(QPointF(0, -(defaultLength - FOUR)));
	originalConnectionPoint.push_back(QPointF(-(defaultLength + dynamicLength - FOUR), 0));
}
开发者ID:candybaby,项目名称:posd-project,代码行数:22,代码来源:ER_ItemRelationship.cpp

示例7: QPoint

void SelectionStrategy::leftButtonPressEvent(int i, int j)
{
    if (selection.contains(i*BLOCSIZE,j*BLOCSIZE)) // move the selection
    {
        deb = selection.topLeft().toPoint() - QPoint(i*BLOCSIZE,j*BLOCSIZE);
        inMove=true;
        selectionOff();
        if (selection==initSelection)
            clearZoneSelected();
        blitTileSelectLayer();
    }
    else //strt a new selection
    {
        blitTileSelected();
        mapView->setSelectionArea(QPainterPath());
        selection.setLeft(i*BLOCSIZE);
        selection.setTop(j*BLOCSIZE);
        selection.setWidth(BLOCSIZE);
        selection.setHeight(BLOCSIZE);
        itemRectSelected->setRect(selection);
    }
}
开发者ID:BenjBoug,项目名称:Map-Editor,代码行数:22,代码来源:SelectionStrategy.cpp

示例8: setAcceptHoverEvents

LinkBox::LinkBox(Route *route, MachineBox *m1, MachineBox *m2)
{
	this->m1 = m1;
	this->m2 = m2;
	this->route = route;

	setAcceptHoverEvents(true);
	setFlag(QGraphicsItem::ItemIsFocusable, true);

	backgrounds << QColor(0x00, 0x00, 0x00) << QColor(0x80, 0x80, 0x80);
	setBrush(QBrush(backgrounds[0]));
	setCursor(Qt::PointingHandCursor);

	basePath = QPainterPath(QPointF(10, 0));
	basePath.lineTo(-5, -10);
	basePath.lineTo(-5, 10);
	basePath.closeSubpath();

	px = py = 0;

	repos();
}
开发者ID:caribe,项目名称:Fado-Sound-Suite,代码行数:22,代码来源:linkbox.cpp

示例9: drawBackgroundAndNumbers

void
drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& figRectIn )
{
    painter->save();

    QRect figRect = figRectIn;
    if ( text.length() == 1 )
        figRect.adjust( -painter->fontMetrics().averageCharWidth(), 0, 0, 0 );

    QPen origpen = painter->pen();
    QPen pen = origpen;
    pen.setWidth( 1.0 );
    painter->setPen( pen );
    painter->drawRect( figRect );

    // circles look bad. make it an oval. (thanks, apple)
    const int bulgeWidth = 8;
    const int offset = 0; // number of pixels to begin, counting inwards from figRect.x() and figRect.width(). 0 means start at each end, negative means start inside the rect.

    QPainterPath ppath;
    ppath.moveTo( QPoint( figRect.x() + offset, figRect.y() + figRect.height() / 2 ) );
    QRect leftArcRect( figRect.x() + offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() );
    ppath.arcTo( leftArcRect, 90, 180 );
    painter->drawPath( ppath );

    ppath = QPainterPath();
    ppath.moveTo( figRect.x() + figRect.width() - offset, figRect.y() + figRect.height() / 2 );
    leftArcRect = QRect( figRect.x() + figRect.width() - offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() );
    ppath.arcTo( leftArcRect, 270, 180 );
    painter->drawPath( ppath );

    figRect.adjust( -1, 0, 0, 0 );

    painter->setPen( origpen );
    painter->setPen( Qt::white );
    painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, QTextOption( Qt::AlignCenter ) );

    painter->restore();
}
开发者ID:demelziraptor,项目名称:tomahawk,代码行数:39,代码来源:TomahawkUtilsGui.cpp

示例10: vecx

QPainterPath DiagonalWipeStrategy::clipPath( int step, const QRect &area )
{
    qreal percent = static_cast<qreal>(step) / static_cast<qreal>(StepCount);

    QPoint vecx( static_cast<int>(2.0 * area.width() * percent), 0 ) ;
    QPoint vecy( 0, static_cast<int>( 2.0 * area.height() * percent ) );

    QPainterPath path;

    switch( subType() )
    {
        case DiagonalWipeEffectFactory::FromTopLeft:
            path.moveTo( area.topLeft() );
            path.lineTo( area.topLeft() + vecx );
            path.lineTo( area.topLeft() + vecy );
            break;
        case DiagonalWipeEffectFactory::FromTopRight:
            path.moveTo( area.topRight() );
            path.lineTo( area.topRight() - vecx );
            path.lineTo( area.topRight() + vecy );
            break;
        case DiagonalWipeEffectFactory::FromBottomLeft:
            path.moveTo( area.bottomLeft() );
            path.lineTo( area.bottomLeft() + vecx );
            path.lineTo( area.bottomLeft() - vecy );
            break;
        case DiagonalWipeEffectFactory::FromBottomRight:
            path.moveTo( area.bottomRight() );
            path.lineTo( area.bottomRight() - vecx );
            path.lineTo( area.bottomRight() - vecy );
            break;
        default:
            return QPainterPath();
    }

    path.closeSubpath();

    return path;
}
开发者ID:KDE,项目名称:calligra,代码行数:39,代码来源:DiagonalWipeStrategy.cpp

示例11: QMatrix

void Context2D::reset()
{
    m_stateStack.clear();
    m_state.matrix = QMatrix();
    m_state.clipPath = QPainterPath();
    m_state.globalAlpha = 1.0;
    m_state.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
    m_state.strokeStyle = Qt::black;
    m_state.fillStyle = Qt::black;
    m_state.lineWidth = 1;
    m_state.lineCap = Qt::FlatCap;
    m_state.lineJoin = Qt::MiterJoin;
    m_state.miterLimit = 10;
    m_state.shadowOffsetX = 0;
    m_state.shadowOffsetY = 0;
    m_state.shadowBlur = 0;
    m_state.shadowColor = qRgba(0, 0, 0, 0);
    m_state.flags = AllIsFullOfDirt;
    m_state.textAlign = Start;
    m_state.textBaseline = Alphabetic;
    clear();
}
开发者ID:ledimies,项目名称:mymoves,代码行数:22,代码来源:context2d.cpp

示例12: updatePath

void SCgPathItem::updatePath()
{
    QPainterPath path;

    if (mPoints.isEmpty())
    {
        mPath.setPath(QPainterPath());
        return;
    }

    path.moveTo(mPoints.first());
    for (int idx = 1; idx != mPoints.size(); ++idx)
        path.lineTo(mPoints.at(idx));


    //Draw path in parent coordinates
    if (mPath.parentItem())
        path = mPath.parentItem()->mapFromScene(path);

//    mPath->setPen(mPen);
    mPath.setPath(path);
}
开发者ID:mcdir,项目名称:sui,代码行数:22,代码来源:scgpathitem.cpp

示例13: spatium

void RepeatMeasure::layout()
      {
      qreal sp  = spatium();

      qreal y   = sp;
      qreal w   = sp * 2.0;
      qreal h   = sp * 2.0;
      qreal lw  = sp * .30;  // line width
      qreal r   = sp * .15;  // dot radius

      path       = QPainterPath();

      path.moveTo(w - lw, y);
      path.lineTo(w,  y);
      path.lineTo(lw,  h+y);
      path.lineTo(0.0, h+y);
      path.closeSubpath();
      path.addEllipse(QRectF(w * .25 - r, y+h * .25 - r, r * 2.0, r * 2.0 ));
      path.addEllipse(QRectF(w * .75 - r, y+h * .75 - r, r * 2.0, r * 2.0 ));

      setbbox(path.boundingRect());
      }
开发者ID:aeliot,项目名称:MuseScore,代码行数:22,代码来源:repeat.cpp

示例14: qwtBorderPath

static QPainterPath qwtBorderPath( const QWidget *canvas, const QRect &rect ) 
{
    if ( canvas->testAttribute(Qt::WA_StyledBackground ) )
    {
        QwtStyleSheetRecorder recorder( rect.size() );

        QPainter painter( &recorder );

        QStyleOption opt;
        opt.initFrom( canvas );
        opt.rect = rect;
        canvas->style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, canvas );

        painter.end();

        if ( !recorder.background.path.isEmpty() )
            return recorder.background.path;

        if ( !recorder.border.rectList.isEmpty() )
            return qwtCombinePathList( rect, recorder.border.pathList );
    }
    else 
    {
        const double borderRadius = canvas->property( "borderRadius" ).toDouble();

        if ( borderRadius > 0.0 )
        {
            double fw2 = canvas->property( "frameWidth" ).toInt() * 0.5;
            QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 );

            QPainterPath path;
            path.addRoundedRect( r, borderRadius, borderRadius );
            return path;
        }
    }

    return QPainterPath();
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:38,代码来源:qwt_plot_abstract_canvas.cpp

示例15: copyItemParameters

void UBGraphicsFreehandItem::copyItemParameters(UBItem *copy) const
{
    UBGraphicsFreehandItem *cp = dynamic_cast<UBGraphicsFreehandItem*>(copy);
    if (cp)
    {
        cp->setPath(QPainterPath(this->path()));
        cp->setTransform(this->transform());
        cp->setFlag(QGraphicsItem::ItemIsMovable, true);
        cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
        cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
        cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));

        if(Delegate()->action()){
            if(Delegate()->action()->linkType() == eLinkToAudio){
                UBGraphicsItemPlayAudioAction* audioAction = dynamic_cast<UBGraphicsItemPlayAudioAction*>(Delegate()->action());
                UBGraphicsItemPlayAudioAction* action = new UBGraphicsItemPlayAudioAction(audioAction->fullPath());
                cp->Delegate()->setAction(action);
            }
            else
                cp->Delegate()->setAction(Delegate()->action());
        }
    }
}
开发者ID:hethi,项目名称:Sankore-3.1,代码行数:23,代码来源:UBGraphicsFreehandItem.cpp


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