Search code examples
qtqt4qpainter

QPainterPath and cubicTo, smooth Line


I am Trying to Connect points by smooth line as shown in Image.

How can i get smooth lines as shown in image?

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

Image:- http://postimg.org/image/44vh9m2ur/


Solution

  • I wrote this code and I got similar result

    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();