Results 1 to 2 of 2

Thread: How to return something not int with a QDialog

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question How to return something not int with a QDialog

    Hi all, I've seen that with the dialog to obtain a color, it returns the color chosen by the user. I want a dialog that returns a QList, for example. Is it possible? or I've to put this list as public in the dialog subclass?

    Thanks all.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to return something not int with a QDialog

    The implementation of those static dialog methods do it like that they first launch a dialog and depending on the result code the desired variable is asked from the dialog and returned..
    Still if it's "hidden" bedind a static method returning something else than a dialogs result code, the internal implementation always checks the result code..

    For example QColorDialog::getColor() looks like this:
    Qt Code:
    1. QColorDialog *dlg = new QColorDialog(parent, true); //modal
    2. dlg->setWindowTitle(QColorDialog::tr("Select color"));
    3. dlg->setColor(initial);
    4. dlg->selectColor(initial);
    5. int resultCode = dlg->exec();
    6. QColor result;
    7. if (resultCode == QDialog::Accepted)
    8. result = dlg->color();
    9. delete dlg;
    10. return result;
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jpn for this useful post:

    SkripT (21st March 2006)

Similar Threads

  1. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 22:48
  2. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 11:25
  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. Once more : QAbstractItemModel woes
    By Valheru in forum Qt Programming
    Replies: 10
    Last Post: 15th January 2008, 11:44
  5. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 18:18

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.