How to get toggled () signal working with QPushButton?

I have the following code where moreButton is QPushButton . When I switch the button, nothing happens.

Do not show or hide secondaryGroupBox and tertiaryGroupBox ?

 QObject::connect(moreButton, SIGNAL(toggled(bool)), secondaryGroupBox, SLOT(setVisible(bool))); QObject::connect(moreButton, SIGNAL(toggled(bool)), tertiaryGroupBox, SLOT(setVisible(bool))); 
+4
source share
1 answer

Most likely your button is not checkable() . Try

 moreButton->setCheckable(true) 

An unchecked button never emits a toggled(bool) signal.

+12
source

All Articles