You don't say what the range of your slider is, but you are probably running into round off error when you divide the integer slider "value" by 100. There is also a bug - if the axis range.center() - value / 100 is less than 0.01 at the end of the -last- slider move, then the range doesn't get updated to the final range. So your optimization to avoid repaints is tripping you up.Could you please help about this problem ? Thanks in advance for your replies..
Try this instead. A trick to detect when the user is dragging the slider (and to avoid excessive repaints) that works no matter what the axis range is:
Create a QTimer as a member of your UI class that holds the slider. When the slider changes (your horzScrollBarChanged() slot), record the current position in a member variable, start or restart the timer with a 250 ms timeout, and then exit the slot. Connect the timeout() signal to another slot where you actually set the new axis range.
As long as the user keeps moving the slider, the timer won't time out (because it is continuously restarted with each move) and the plot won't be repainted. As soon as the slider stops moving for 250 ms, the timeout will trigger the repaint. You can do variations on this - repaint the window every 'n' moves or when the change has become 'large enough' so the plot stays alive. Depends on how fast the plot can repaint. In any case, you never have to check for the size of the change, and the last slider position is always processed.
Bookmarks