0

I'm using Qt 5.10. I'm trying to update a QImage with setPixMap and QLabel, by connecting the QSlider to a value changed signal, but the QSlider lags noticeably when I slide it normally.

I found a related question but the answers aren't helpful: qt qslider not smooth

Is this a QSlider issue or am I using it wrong?

ALH
  • 85
  • 4
  • 14
  • provide a [mcve] – eyllanesc Apr 30 '18 at 22:29
  • 2
    Are you trying to update image right after the slider value have changed? This might be the reason for the lag: updating image consumes too much time so that the event loop hangs. After the image update is done the event loop is running again, but the mouse cursor has moved quite a lot, that results in slider movement not being actually smooth. Try deferring the image update or perform it asynchronously. Consider caching changed the image with `QPixmapCache` or `QCache` if it is possible in your application. – Innokentiy Alaytsev Apr 30 '18 at 23:04
  • I've tried putting the image update in an asynchronous thread, but it still lags. QPixmapCache probably wouldn't work for my case since I'm try to process the image and update the QImage after. – ALH May 01 '18 at 05:16
  • `QPixmapCache` will not help the first time you set parameter with `QSlider`. But if you change processing parameter back to previous value then you can just take previously computed pixmap without recomputation. In case where you have multiple processing parameters you may want to use their values to create keys for pixmap cache to be able to reuse previously computed pixmaps. As for asynchronous computation: could you please provide an example of your code that uses asynchronous thread to compute image? Also, consider image recomputation only after some time after `QSlider` value change. – Innokentiy Alaytsev May 01 '18 at 10:54

0 Answers0