PDA

View Full Version : using signals and slots to do action on mainwindow when child dialog is closed



aldm
22nd May 2011, 00:42
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()));
d->show();

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.

Thanks,

Amer

Zlatomir
22nd May 2011, 00:53
You can have a look at QDialog's accepted (http://doc.qt.nokia.com/latest/qdialog.html#accepted), finished or rejected signals.

Or if this is not enough i think you could derive from QDialog and override closeEvent (you can call some function there or emit a signal there - i didn't try this but i guess it should work - maybe you can wait for more experienced opinions about this)