PDA

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



webquinty
13th May 2009, 18:54
Hello,

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

Lykurg
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.

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

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

wysota
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.