PDA

View Full Version : check box and signal



mickey
20th March 2006, 17:14
Hi, I'm trying to do this:

connect( checkBox, SIGNAL(toggled(bool)), this, SLOT (activeOption() ));
connect( checkBox2, SIGNAL(toggled(bool)), this, SLOT (activeOption() ));

problem is that check box belog to button group exclusive of 2 check box; When I active check1 start my SLOT and SLOT starts a second time because when checking the fisrt box, I de-checking the second too (is exclusive); I need something like:
connect( checkBox2, SIGNAL(checked()).....but it is not a signal?
is there a signal?
Thanks

zlatko
20th March 2006, 17:43
emm..why you dont want get bool flag(checked/unchecked) in your slot :confused:

jpn
20th March 2006, 18:17
Since you have the check boxes in a button group, you can use:
QButtonGroup::clicked(int id) [signal] (http://doc.trolltech.com/3.3/qbuttongroup.html#clicked)

At least in Qt4, the corresponding signal is emitted for the check box that was "checked".

mickey
20th March 2006, 19:47
emm..why you dont want get bool flag(checked/unchecked) in your slot :confused:
because I'd like the SLOT starts only when checkBox is checked and avoid control of a bool inside SLOT; I resolve so:

connect(buttonGroupEquation, SIGNAL(clicked(int)), this, SLOT (activeOption(int) ));
clicked(int) say to SLOT who is the sender too; Thanks

MarkoSan
7th November 2007, 11:53
Is it possible to change checked window's contens (caption and icon) regarding to this button check state? I mean, how do I rewrite non virtual slot to do this?

jpn
10th November 2007, 10:17
Is it possible to change checked window's contens (caption and icon) regarding to this button check state? I mean, how do I rewrite non virtual slot to do this?
Could you elaborate a bit? What is a checked window? What non-virtual slot?

MarkoSan
10th November 2007, 11:15
Ok, here we go:

The checked button term is used in qt QPushButton documentation and it refers to a button, which supports toggle button. And here is my problem, since i do not know how to make a code that will:

1) in button state ON set a predefined text and icon
2) in button state OFF set a different predefined text and icon

jpn
10th November 2007, 15:21
Construct a QIcon with two pixmaps, one for each state. To update button text, you can simply connect to toggled(bool) signal and set the button text in the corresponding slot, or you can reimplement for example QAbstractButton::checkStateSet() and change the button text there.