[!!!核心方法!!!]
使用带参数的replot()函数绘制m_pCustomPlot>replot(QCustomPlot::rpQueuedReplot)
1. replot() 方法
void QCustomPlot::replot(QCustomPlot::RefreshPriority refreshPriority = rpImmediateRefresh)
- replot() 用于重新绘制 QCustomPlot 控件的图像。
- 参数 refreshPriority 控制刷新优先级,可选值:
2. rpQueuedReplot 的作用
m_pCustomPlot->replot(QCustomPlot::rpQueuedReplot);
等效于:
QMetaObject::invokeMethod(m_pCustomPlot, "replot", Qt::QueuedConnection);
- 不会阻塞 UI 线程,提高绘图性能。
- 避免多次 replot() 影响帧率(如实时绘制数据时)。
- 适用于高频更新的绘图场景(如实时频谱分析、瀑布图)。
3. rpQueuedReplot VS rpImmediateRefresh
4. 使用场景及结论
✅ rpQueuedReplot 适用于:
- 实时频谱图(如 IQ 数据绘制)。
- 瀑布图(Waterfall Display)。
- 高频率数据更新(如 30FPS 以上)。
✅ rpImmediateRefresh 适用于:
- 用户交互(如手动缩放、拖拽)。
- 低频刷新(如手动点击按钮触发绘图)。
✅ 结论:
- 高频绘图 → rpQueuedReplot(推荐)。
- 用户交互时 → rpImmediateRefresh。
🚀 你的项目如果是实时绘制 IQ 频谱或瀑布图,建议使用 rpQueuedReplot 提高性能!