How to do repaint as parts
Problem is that I have a lot of data to plot and I would like to keep UI responsive. Application is QML that uses own QGraphicsWidget based item to show data. I already cache all data to be plot as QVector<QLine> data; and plot it with painter->drawLines(data); Issue is that that takes too much time when i scroll my view with finger.
I could make it faster if I could plot it as a part by part, plot only some part when it is moved and when moving pauses, fill details on it.
I Use QTimer::singleShot(0, this, SLOT(idlePlot())) to schedule next round of the plot. In idlePlot() I use update() to schedule update plot, I have set QGraphicsWidget::setAutoFillBackground(false); on constructor.
Now there is two issues:
1- How I could find ou difference between my self queued events to draw next part and system created events and when i shoud redraw from beginning like in case when i scroll view. Using rectangle does not work because I would like to draw all area and then add details later. Other problem is that it clips plot with update rectangle even if I set on painter painter->setClipRect(boundingRect()); I tried to use rectangle size as indicator of partial plots but it did not work for this reason. Just some method of passing single bit flag from update() to paint() is needed.
2- Even I set QGraphicsWidget::setAutoFillBackground(false);, It still overpaints all things I plot in previous phase with background color when I schedule new event with update(QRect(..)) How i could turn redaw backgroud off so that I could just add details over part plot in previous phase ?
QPainter *painter is just given as parameter of paint(), it is not available wia QGraphicsWidget, so I can't drirectly get it from my idlePaint function. I am aware of Z-ordering but my view is topmost, it is not an issue.
I got some kind of working solution so that I use timer with some delay to redraw all when movement stops but this is not perfect because if user is just moving slowly, UI is unreponsive.
Any good solutions ? Or is QPixelBuffer with OpenGL render only way ?