PDA

View Full Version : QtCharts delayed legend repaint



WolfByte
14th October 2022, 13:44
I'm trying to move the line legend to a new location and then use the grab() routine to save an image to disk. My saved image has the legend in the previous location because of a delay in rendering. Calling processEvents() is not helping me in this case. Any advice?

d_stranz
14th October 2022, 17:15
Maybe try using a single-shot QTimer to delay the grab? My understanding (possibly incorrect) is that QTimer will fire only after the event queue is empty. Alternatively, try using QWidget::render() instead of grab(). I think grab() makes a copy of the on-screen pixels, whereas render() actually redraws the widget into the image.

WolfByte
14th October 2022, 18:17
Maybe try using a single-shot QTimer to delay the grab? My understanding (possibly incorrect) is that QTimer will fire only after the event queue is empty. Alternatively, try using QWidget::render() instead of grab(). I think grab() makes a copy of the on-screen pixels, whereas render() actually redraws the widget into the image.

Unfortunately, the QWidget::render() did not fix the problem. Same issue. The single-shot QTimer I feel would fix my problem in most cases. However, if the user is setting a large dataset I'm not guaranteed the timer has enough milliseconds on it to account for that. Any other ideas? Thanks for the suggestions by the way, I had not tried those.