PDA

View Full Version : return-value and QDialog



homerun4711
15th February 2011, 15:38
Hello!

I have a question about returning a value from a QDialog that ist about to be closed.

An instance of InvoiceEdit is created first:


InvoiceEdit *editInvoice = new InvoiceEdit();

if (editInvoice->exec())
{
...
}

This class contains a private function like



int InvoiceEdit::saveInvoice()
{
...
this->close();
return 0;
}


Will the value be returned or is the instance of InvoiceEdit destroyed due to the call of close() ? And since the value is passed (if it is..) to another private function, when will the closeEvent kick in and destroy the instance? Are all functions completed before is is closed?

Kind regrads,
HomeR

szisziszilvi
16th February 2011, 08:39
isn't there a way to print a note if it was retured (and another if not)? because if it should then I'm quite sure you can catch it somewhere and give some kind of output of its nature, eg. to console or some testfile. It seems to me a simle bug-fixing-searching problem.

homerun4711
16th February 2011, 09:47
Thanks for your answer. Yes, for sure it would be possible to solve this by try and error, but I am more interested in a more detailed answer about how long the life cycle of such elements is.

szisziszilvi
16th February 2011, 14:42
well, you will se if you try... :)

drave
16th February 2011, 16:34
I think calling done() with either accept or reject might be better than close().

The dialog instance is hidden and processing stopped when you dismiss it but it will not be destroyed until you destroy it "delete editInvoice".
You can read any public widget values or your own properties/variables etc until then

regards

Dave