Results 1 to 3 of 3

Thread: how to program custom Dialogs with return values

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default how to program custom Dialogs with return values

    Hi,
    I wonder how to write modal Dialogs executed with QDialog::exec(), that provide a result other than integer values ( which can be easily achieved with QDialog::accept(), QDialog::reject() and QDialog::setResult() ). Since there are Dialogs that return objects like QFonts, QColors etc. all over Qt4, I guess there must be a (simple) mechanism to do that. Any Ideas?

    thanx in advance
    momesana

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to program custom Dialogs with return values

    Quote Originally Posted by momesana View Post
    Since there are Dialogs that return objects like QFonts, QColors etc. all over Qt4
    Yes, but they either use static methods or signals.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to program custom Dialogs with return values

    Of course you can always do something like this:

    Qt Code:
    1. class MyDialog : public QDialog {
    2. public:
    3. // ...
    4. QString myExec(){
    5. if(exec())
    6. return myresult();
    7. else return "";
    8. }
    9. private:
    10. QString myresult() const { return ... }
    11. };
    To copy to clipboard, switch view to plain text mode 

    and call it using
    Qt Code:
    1. MyDialog dlg;
    2. QString r = dlg.myExec();
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to wysota for this useful post:

    momesana (23rd December 2006)

Similar Threads

  1. Replies: 4
    Last Post: 24th March 2006, 22:50
  2. Limiting values for custom designer properties
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 12:27
  3. Problem with custom widget
    By jnana in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2006, 11:55

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.