Results 1 to 5 of 5

Thread: return-value and QDialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default return-value and QDialog

    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:

    Qt Code:
    1. InvoiceEdit *editInvoice = new InvoiceEdit();
    2.  
    3. if (editInvoice->exec())
    4. {
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 

    This class contains a private function like

    Qt Code:
    1. int InvoiceEdit::saveInvoice()
    2. {
    3. ...
    4. this->close();
    5. return 0;
    6. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: return-value and QDialog

    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.
    Szilvi

  3. #3
    Join Date
    Oct 2010
    Posts
    91
    Thanks
    38

    Default Re: return-value and QDialog

    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.

  4. #4
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: return-value and QDialog

    well, you will se if you try...
    Szilvi

  5. #5
    Join Date
    Dec 2009
    Posts
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: return-value and QDialog

    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

  6. The following user says thank you to drave for this useful post:

    homerun4711 (16th February 2011)

Similar Threads

  1. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 12:35
  2. Replies: 2
    Last Post: 27th June 2009, 20:26
  3. How to return a lot of data from a QDialog
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2008, 13:10
  4. Return key in an editable QComboBox accepts a QDialog
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 16:56
  5. How to return something not int with a QDialog
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2006, 18:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.