PDA

View Full Version : How to return something not int with a QDialog



SkripT
21st March 2006, 16:53
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.

jpn
21st March 2006, 17:05
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:


QColorDialog *dlg = new QColorDialog(parent, true); //modal
dlg->setWindowTitle(QColorDialog::tr("Select color"));
dlg->setColor(initial);
dlg->selectColor(initial);
int resultCode = dlg->exec();
QColor result;
if (resultCode == QDialog::Accepted)
result = dlg->color();
delete dlg;
return result;