[Qt-interest] Signal-Slot not working

Martin Fiala fialkam at gmail.com
Mon Mar 23 11:34:52 CET 2009


I don't really clearly understand.. But to me it looks like
"contactos_created" stays false all the time..
If you want to change it, you could assign it after creating the
newForm, where it sems logical to be set to true...
But it surely doesn't explain why the program finishes unexpectedly...

On Sun, Mar 22, 2009 at 8:15 PM, algajard <algajard at gmail.com> wrote:
> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list