PyQt5 QSpinBox – Adding looping
In this article we will see how we can add looping to the spin box, when we create a spin box by default when it reaches the maximum value it can’t be incremented any more similarly when it reaches minimum value it can’t be decremented any more. By adding looping to the spin box the values repeat it self after the maximum or minimum value is reached.
Implementation steps :
1. Create a window
2. Create a spin box
3. Set range of the spin box such that it has one extra value for minimum and maximum value for example if we want values from 0 to 100 set range to -1 to 101
4. Add action to the spin box such that every time its value changes action should get called
5. Inside the action get the current value of the spin box.
6. Check if current value is equal to the minimum value then set current value of spin box to maximum value – 1
7. Else check if current value is equal to maximum value then make current value of spin box to minimum + 1
Below is the implementation
Please Login to comment...