View Full Version : How to return a lot of data from a QDialog

20th October 2008, 12:47
I'm writing a dialog and when the user is clicking ok in the dialog, the dialog should send all the data that has been entered back to the mainwindow. As I see it I have two options.
When creating the dialog, send a pointer to the mainwindow and call a function parent->doStuff(...config data...);

or do this with signals and slots, but that seems a little overkill, calling connect and disconnect(?) to release the signals/slots.

Are there more options for doing this?
Any way that is considered to be the "best"?

20th October 2008, 13:04

Ideas are quite good, but I would not send mainwindow's pointer to it's child, why? It is too dangerous. I would thing about additional methods, depending on the amount of data you need to "configure":
1) create a custom data structure which will store the configuration data in the dialog and the dialog, before being destroyed, can return the data to the mainwindow.
2) you can have the configuration data in the mainWindow and send it as a pointer to the dialog; the dialog would then override the data and after comming back to mainwindow you would have the data you need.
3) if you need to react to whenever the data is changed in the mainwindow and cannot wait till the dialog will be closed you can do the same + adding a signal to notify the mainWindow that the data has changed.
I suppose there may be some other solutions;
You should concentrate that the code will be easy to modify and be safe.


20th October 2008, 13:10
Your suggestions 2 and 3 sounds best.