Connect QButton :: pressed and send qobject::name + bool value (because toggle)
-
In main windows I would insert 10 Qbutton (checkable) ... normally if connect on void we can use check state for make a if true/false function .... but I would use the same function for all toggle and pass the name of widget everytime is check to that function ... Need to reimplement QpushButton or there are a better and short way?
regards
bkt -
You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.
-
@Christian-Ehrlicher said in Connect QButton :: pressed and send qobject::name + bool value (because toggle):
You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.
thanks a lot ....
QPushButton *btnOn = dynamic_cast<QPushButton*>(sender()); QString pepperOn = btnOn->text();
Is the right way? Any who it work.
-
@gfxx said in Connect QButton :: pressed and send qobject::name + bool value (because toggle):
Is the right way?
When using a dynamic cast (or object cast) the return value can be a nullptr - you should check for this.