如何在QT中的两个已知点之间绘制弧线?

发布于 2025-02-06 01:04:32 字数 674 浏览 2 评论 0原文

我想在点d点之间绘制一个弧度,它应该触摸到E。(我想绘制和门符号)
我尝试过这种方式

QPainterPath path;    
path.arcTo(60,30,46,100,30*16,120*16); // ( x,y,width,height, startAngle,spanAngle)       

,但它正在绘制完整的圆圈,而不是在适当的位置。

当前看起来像

在此处输入图像描述”> 得到建议,我尝试了这样的建议:

path.moveTo(106, 80);
path.arcTo(76.0, 30.0, 60.0, 100.0, 90.0, -180.0);    

如何摆脱该垂直线(内部和门)?
为什么出现?

enter image description here

I want to draw an arc between point B to point D and it should touch to point E. ( I want to draw AND gate symbol )
I tried this way

QPainterPath path;    
path.arcTo(60,30,46,100,30*16,120*16); // ( x,y,width,height, startAngle,spanAngle)       

But it is drawing full circle and not in proper place.

Currently it is looking like this

enter image description here

After getting suggestion I tried like this :

path.moveTo(106, 80);
path.arcTo(76.0, 30.0, 60.0, 100.0, 90.0, -180.0);    

How to get rid of that vertical line ( inside AND gate ) ?
Why it is appearing ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2025-02-13 01:04:34

我认为您误解了

给定图像,您应该将路径移动到(106,80)(边界矩形中心)

path.moveto(106,80);

界限矩形

  • Y:30
  • 宽度:60
  • 高:100

弧itsel应在90°上具有启动角,并且应跨度180°在负方向上。

这将导致:

path.arcto(76.0,30.0,60.0,100.0,90.0,-180.0);

更新

arcto

path.moveTo(106, 30);
path.cubicTo(QPointF(156.0, 30.0), QPointF(156.0, 130.0), QPointF(106.0, 130.0));

I think you misunderstood the parameters for arcTo, especially the bounding rectangle.

Given your image, you should move path to (106, 80) (center of the bounding rectangle)

path.moveTo(106, 80);

The bounding rectangle of the arc should look like this:

  • x: 76
  • y: 30
  • width: 60
  • height: 100

The arc itsel should have a start angle at 90° and should span 180° in negative direction.

This results in:

path.arcTo(76.0, 30.0, 60.0, 100.0, 90.0, -180.0);

Update

arcTo

path.moveTo(106, 30);
path.cubicTo(QPointF(156.0, 30.0), QPointF(156.0, 130.0), QPointF(106.0, 130.0));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文