Please nominate your Qt Champions for 2021!

[RESOLVED] Can't emit signal on dialog close

  • Hello.

    Here is my problem I have two dialogs, and when I close firs dialog, I want that second closed too.

    I'm using signals and slots, and emiting signal from first dialog witch triggers slot in other dialog, this slot looks like this:

    @void Dialog2::CloseSecondDialog(void)

    The problem is that I can't emit signal onDialogClose , it just don't woking, and I don't know why ? My code:

    emit CloseSecondDialog();
    delete ui;


    I made some tests and tried to emit signal from other place for example, after buton click:

    @void Dialog1::on_pushButton_clicked()
    emit CloseSecondDialog();

    And it worked perfectly. So why it's not working when Dialog is closed ?

    Sory for my english.

  • You should emit signal in "closeEvent": not in destructor.

  • Thanks for help.

    Since one of the dialogs are model and other modeless, I got it working like this:


    And it's working perfect for my :D.
    But I think I will do it the right way and use closeEvent.

    Thanks again for both answers.

Log in to reply