PDA

View Full Version : QT4 signal/slot



incapacitant
14th March 2006, 07:55
In the following code the SLOT(Ok()) is not triggered when the user presses the pushbutton Ok. I have either to put "accept" or "close". As it is here the window is not closed or only with cancel

I don't understand this behaviour, what have I done wrong ?



pbOk = new QPushButton( "Ok", this);

connect( pbOk, SIGNAL( clicked() ), this, SLOT( Ok() ) ); // <--- does not work
connect( pbCancel, SIGNAL( clicked() ), this, SLOT( close() ) );

}

//************************************************** ***********
void Destinataires::Ok()
{
accept(); // does not work either with emit accept, emit close
close();
}


Thanks for helping me out !

incapacitant
14th March 2006, 08:07
I forgot to add "private slots:" in the class declaration. All works well. Sorry.

wysota
14th March 2006, 12:30
How about just:


connect( pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );