Solved PushButton setDisable Issues
-
Dear All,
When a PushButton is disabled all its signals are disabled automatically?
Is possible disable temporary the button and maintaining his signals when It will re-enabled? -
@Simof
A disabled widget does not generate (normal) signals. Yes when it is reenabled it reverts to sending signals, and any slots connected are preserved. -
@Simof said in PushButton setDisable Issues:
When a PushButton is disabled all its signals are disabled automatically?
no, disabled means it wont react to/process certain events
Is possible disable temporary the button and maintaining his signals when It will re-enabled?
about what signals are you talking about? and whats the actual use case you are after?
if its just the clicked signal you can install an eventfilter on the button. -
Then you are using the
disabled
property wrong. If you disable a button, there should not be any user interaction going on (because there's probably a reason why you disabled this button).You want to store your signals in some sort of queue and send them as soon as the button get enabled again?! Is this what you are trying?
Changing theenabled / disabled
state, doesn't do anything to your slots connected to the button.In general an enabled widget handles keyboard and mouse events; a disabled widget does not. An exception is made with QAbstractButton.
(https://doc.qt.io/qt-5/qwidget.html#enabled-prop)
Note: As opposed to other widgets, buttons derived from QAbstractButton accept mouse and context menu events when disabled.
-
Thanks for your answer.
I made this question because when i disable and next re-enable the qpushbutton its signal "clicked()" don't call my slot.
I'll try to understand why!
-
@Simof said in PushButton setDisable Issues:
I'll try to understand why!
At least not because you disable/enable the button. Please show a minimal, compilable example for your issue.
-
I understand the mistake.
I'm using a custom class hinerit from QPushButton and I rewrite the setDisabled() function.
I thought I was enabling it correctly but it wasn'tvoid ClickableLabel::setDisabled(bool en) { if(en) { QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect(); effect->setOpacity(0.4); this->setGraphicsEffect(effect); ---> BEFORE <--- QPushButton::setDisabled(en); } else { if(enShadow) setUnpressedShadow(); } ---> AFTER<--- QPushButton::setDisabled(en); }