How to enable a disabled button

I have a toolbar that I want to turn off when I click on it (if it's on) and turn it on when I click on it (and it's off). The problem is that when I clicked on it, I wrote the corresponding slot and turned off the button. While it works. But as soon as you turn it off and you click on it, it won’t go into the slot, it’s completely disconnected forever. Am I using the wrong function or the wrong signal?

... bool mEnable = true; void Test::OnEnableButtonTriggered() { mEnable = !mEnable; ui.OnEnable->setEnabled(mEnable); } 
+4
source share
1 answer

You cannot start the disabled button directly, but even if it is possible, you most likely will not want to do this, as it is rather annoying.

I would suggest using QCheckbox for what you are trying to achieve.

If you still want to use the disabled button, you can check this post:

Qt 4.4: disabled widgets that accept mouse events

+3
source

Source: https://habr.com/ru/post/1435862/


All Articles