Unsolved Button which will be in pressed state when it's clicked
-
Hey , everyone. I started learning pyQt and I want a button which will when clicked always in pressed state and when it's going to be clicked again , it's going to be released. I guess it can be achieved with QtWidgets.QPushButton, but which flags to use I don't know. I tried to read all of them , but a lot still looks so hard to grasp. Can anybody help newbie ? Thanks
-
Hi and welcome to the forums.
QPushButton has this feature and its called Checkable/toggle
http://doc.qt.io/qt-5/qabstractbutton.html#checkable-prop
its off by default , so you must set setCheckable(true);
You can use the signal
http://doc.qt.io/qt-5/qabstractbutton.html#toggled
to know when pressed/released aka checked / unchecked.So you just create the buttons as normal, then
button.setCheckable(true)
Then use connect to hook up
its toggled signal if u want to do stuff when its down / up. -
Awesome, thanks a lot !