[Qt-interest] Signal-Slot not working

algajard algajard at gmail.com
Sun Mar 22 20:15:16 CET 2009


Hey list,

I've a problem with signals and slots. I created a signal for a QWidget 
for closing and a slot in other QWidget with a slot that receive this 
signal and update somes inner states. The problem is that apparently the 
signal is not recieved by the slot.

Here is the signal


void ContactosForm::closeEvent(QCloseEvent *event)
{
     emit closing();
     event->accept();
}

Here is the slot (is a private slot).

void ClientesForm::contactos_closing()
{
     this->contactos_created=false;
}

and this is the Constructor of the second widget.

ClientesForm::ClientesForm(QWidget *parent) :
     QWidget(parent){
     setupUi(this);
     contactos_created=false;
     newForm=new ContactosForm;
     connect(newForm,SIGNAL(closing()),this,SLOT(contactos_closing()));
}

The thing is that I open the ContactosForm from ClientesForm. Then I 
close the ContactosForm and then ClientesForm and QtCreator tells me 
*The program has unexpectedly finished.*

This is the close event for ClientesForm

void ClientesForm::closeEvent(QCloseEvent *event)
{
     if( contactos_created )
     {
         newForm->parentWidget()->close();
         delete newForm;
         contactos_created=false;
     }
     event->accept();
}

As you see, when the signal is emitted and received by the ClientesForm 
widget, it's supposed that the value of /contactos_created/ should 
chante but this is not happening.

Any clues ? Suggestions ?

Thanks.

Greetings.

-- 
"Talk is cheap. Show me the Code"
"'Regression testing'? What's that? If it compiles, it is good, if it 
boots up it is perfect."
-----------------------
Alvaro Esteban Gajardo Becerra
Estudiante Informática - Universidad del Bío Bío
Linux User #407663 counter.li.org
Chillán
Chile



More information about the Qt-interest-old mailing list