0

As you can see, my code is very simple, it only calls QLineSeries.replace(QPolygonF) periodically.

But when the code executes, memory the application used keeps on increasing.

import sys

from PyQt5.QtCore import QTimer
from PyQt5.QtGui  import QPolygonF
from PyQt5.QtWidgets import QApplication, QMainWindow

from PyQt5.QtChart import QChart, QChartView, QLineSeries

class DemoWindow(QMainWindow):
    def __init__(self, parent=None):
        super(DemoWindow, self).__init__(parent=parent)

        self.plotChart = QChart()
        self.plotChart.legend().hide()

        self.plotView = QChartView(self.plotChart)
        self.setCentralWidget(self.plotView)

        self.plotCurve = QLineSeries()
        self.plotChart.addSeries(self.plotCurve)

        self.plotChart.createDefaultAxes()

        self.polyline = QPolygonF(1000)

        self.tmrPlot = QTimer()
        self.tmrPlot.setInterval(100)
        self.tmrPlot.timeout.connect(self.on_tmrPlot_timeout)
        self.tmrPlot.start()

    def on_tmrPlot_timeout(self):
        self.plotCurve.replace(self.polyline)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = DemoWindow()
    win.show()
    sys.exit(app.exec_())
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
XIVN1987
  • 1
  • 2

0 Answers0