View Full Version : Two groupbox, if checked one, uncheck other

13th May 2009, 18:54

I have this code:

QObject::connect(groupBox, SIGNAL(clicked(bool)), groupBox_2, SLOT(setChecked(bool)));
QObject::connect(groupBox_2, SIGNAL(clicked(bool)), groupBox, SLOT(setChecked(bool)));

But It do not want it.
I am interesting in if I checked groupbox, unchecked groupbox2 and vicerversa.
any advice?

best regards

13th May 2009, 19:08
make your own slot a) two for both group boxes b) only one and use sender to figure out which group box was sending the signal. Or use QSignalMapper.

13th May 2009, 20:00
Use a QButtonGroup and make it exclusive.

13th May 2009, 21:31
Thanks a lot wysota and Lykurg.

14th May 2009, 00:40
Actually my solution is incorrect. I read your post too quickly and didn't see you were talking about a groupbox and not a checkbox. Obviously my solution works only for buttons.