【问题标题】:QPainterPath and cubicTo, smooth LineQPainterPath 和cubicTo,平滑线
【发布时间】:2014-08-12 07:41:40
【问题描述】:

我正在尝试用平滑线连接点,如图所示。

我怎样才能得到如图所示的平滑线条?

QPainterPath myPath(A);
myPath.cubicTo(A,A,B);
myPaht.cubicTo(B,B,C);
myPath.cubicTo(C,C,D);
myPainter.drawPath(myPath);

图片:-http://postimg.org/image/44vh9m2ur/

【问题讨论】:

    标签: qt qt4 qpainter


    【解决方案1】:

    我写了这段代码,得到了类似的结果

    QPainterPath myPath(QPointF(50,50));//start point
    myPath.cubicTo(60,25,80,80,90,60);  //set another points
    
    scene->addPath(myPath,QPen(Qt::red));//I use graphicsscene, but you can use, what you want
    ui->graphicsView->setScene(scene);
    ui->graphicsView->show();
    

    【讨论】:

    • 感谢您的回复。如何为超过 4 个点绘制类似的平滑路径?大约100分。使用两个 QPainterPath.cubicTo(从上一个 End 开始下一个)不会创建平滑线。关于为附加图像中的黑框创建剪切矩形/区域的任何评论?
    猜你喜欢
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 2021-09-30
    相关资源
    最近更新 更多