PDA

View Full Version : question on connect



mickey
11th June 2006, 11:04
Hi, i coded this; it happend a strange thing: buttongroup contan several checkboxes
when I check one, the SLOT is called; but when I uncheck one, the SLOT is called twice...
Is there a QT reason for this? thanks


connect(lightd->buttonGroupLL, SIGNAL(clicked(int)), this, SLOT(activeTabLight(int)));

fullmetalcoder
11th June 2006, 11:14
I guess there is if your checkboxes are mutually exclusive and that none is checked when your app starts... Otherwise this might be a bug but I can't be sure without seeing your code...

mickey
11th June 2006, 12:53
buttonGroupLL isn't exclusive and checkboxes are disable at startup....
I put a printf inside activeTabLight and when I disable a checkbox, it starts twice...

mickey
12th June 2006, 16:18
Hello everybdy. I'm understand the real problem; this is my code
Every time the openLightDialog() is called, it seems the connect below is duplicated: the SLOT starts many time how I called openLightDialog(); eg if I call openLightDialog() 3 times, when a signal occurs, activeTabLight(int) is called 3 time instead one; I tried to put a disconnect at the end (but I don't like it). Furthermore, it seems that disconnect conficlits with a connect inside myLightDialog() constructor....


myLightDialog::myLightDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
:lightDialog (parent, name, modal, fl) {
connect (this->buttonGroupLL, SIGNAL(clicked(int)), this, SLOT(pushButtonLight(int))); // with disconnect at the end, this doesn't work!!
}



void myMainForm::openLightDialog() {
vector <QCheckBox*> cbl;
cbl.push_back(lightd->checkBoxL0);
................................
for (int i=0; i<8; i++)
connect(cbl[i], SIGNAL(stateChanged(int)), this, SLOT(activeTabLight(int)));
if(lightd->exec()){
DoSomething();
......................
}
for (int i=0; i<8; i++) {
cbl[i]->disconnect();
}

How to do this? maybe Do I have to destroy that vector anywhere?
thanks

wysota
12th June 2006, 22:02
Maybe you should make the connection in a different place in code?

mickey
14th June 2006, 12:09
yes, it's right; I put it in other place; but i don't understand a thing; the vector should be destroy at the end of this method...(?) and connect is aliving? What happened, please....

jacek
14th June 2006, 13:50
the vector should be destroy at the end of this method...(?) and connect is aliving?
That vector contains pointers and only those pointers will be removed --- objects they point to won't be deleted.