Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get toggled() signal working with a QPushButton?

I have the follwing code where moreButton is a QPushButton. When I toggle the button, nothing happens.

Shouldn't it 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)));
like image 581
Iceman Avatar asked Jun 15 '12 01:06

Iceman


1 Answers

Most likely, your pushbutton is not checkable(). Try

moreButton->setCheckable(true)

A non-checkable button never emits the toggled(bool) signal.

like image 113
Kuba hasn't forgotten Monica Avatar answered Oct 06 '22 04:10

Kuba hasn't forgotten Monica