[!!!核心方法!!!]
使用帶參數的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 提高性能!