PyQt5 QSpinBox – Connecting two spin boxes with each other
In this article we will see how we can connect two spin boxes with each other such that every time value change in the one spin box should reflect in other spin box as well for example when we have fixed the width to height ratio of image and allow user to set width and height using spin box, as ratio is fixed therefore change in any dimension should also reflect in the other dimension.
Two spin box connected to each other such that there value should remain equal for every change of value occur in any of the spin box.
Steps for implementation :
1. Create two spin box
2. Add geometry to both the spin box
3. Add action to each spin box using valueChanged signal
4. Inside the first spin box action get the current value of spin box and set this value to the second spin box
5. Inside the second spin box action get the current value of spin box and set that value to the first spin box
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course