Important: Please read the Qt Code of Conduct -

How to sent signal to mainwindow when child dialog is closed

  • Hi,

    I'm new in QT and i have some problems with signals and slots.
    I created and showed dialog on main window (when user click on graph, dialog is shown). Now, I want when close this dialog, to execute slot action defined on main window (draw text on mainwindow graph). Paert of mainwindow code:

    Dialog *d=new Dialog();
    connect(d, SIGNAL(d->finished(int)), this, SLOT(iscrtaj()));

    This is code for showing dialog after clicks on graph.

    In mainwindow, I defined slot called iscrtaj and implement it just to show message box (for test).
    This doesn't work. When dialog is closed, nothing is happening.

    I tried the same code, just in constructor of dialog, so slot is implemented in dialog:

    @connect(this, SIGNAL(d->finished(int)), this, SLOT(iscrtaj()));@

    and it works.

    So, problem is to link mainwindow and dialog.
    Can anybody tell me how?

    This is really urgent for me. I appreciate any kind of help.



  • Maybe
    instead of
    @SIGNAL(d->finished(int))@ ?

  • It doesn't work. I also changes first argument from this to d (because when d is dinished, signal shoulčd be sent), but it also doesn't work.

    Thank you for your answer anyway

  • try this in mainwindow constructor :

    @ myDialog* d = new myDialog(this);
    connect(ui->pushButton,SIGNAL(clicked()), d, SLOT(show()));//here you show the dialog by clicking on your graph,
    // i use pushbutton instead
    connect(d,SIGNAL(finished(int)), this, SLOT(iscrtaj()));@
    I made i small workable example with a mainwindow and a dialog and it works for me like this.

    just added in mainwindow :

    @public slots :
    void iscrtaj(){qDebug() << "testconnect";}@

Log in to reply