You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在QtChart中添加独立的垂直线?

QtChart双Y轴图表添加独立垂直线的问题

我有一个包含两个Y轴的QtChart图表,需要在特定位置添加垂直线。这些垂直线需从y=0处起始,延伸至图表区域的最大值(超出图表区域也无妨)。但当我使用QLineSeries绘制这些点时,所有点会被连接起来,无法得到独立的垂直线效果。我尝试通过添加QPointF(NAN, NAN)来设置点之间的间隔,但没有效果。

尝试过的代码:

PhaseSeries->append(curRec.Second, 0);
PhaseSeries->append(curRec.Second, 500);//maxValue for the phase to reach the upper side of the graph
PhaseSeries->append(QPointF(NAN, NAN));

临时解决方案

我找到了一个在当前场景中可行的方法,但写法不够优雅:

PhaseSeries->append(curRec.Second, -500);
PhaseSeries->append(curRec.Second, 500);//maxValue for the phase to reach the upper side of the graph
PhaseSeries->append(curRec.Second, -500);

内容的提问来源于stack exchange,提问作者Salvatore Villani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 04:33:11