Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QColor QColorDialog::getColor ( const QColor initial = Qt::white,
QWidget parent = 0 
) [static]

Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial. The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog. All colors allocated by the dialog will be deallocated before this function returns.

Definition at line 1532 of file qcolordialog.cpp.

References color(), QDialog::exec(), QColorDialog(), QDialog::result(), selectColor(), setColor(), and QWidget::setWindowTitle().

Referenced by MainWindow::penColor().

{
#if defined(Q_WS_MAC)
    return macGetColor(initial, parent);
#endif

    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;
}


Generated by  Doxygen 1.6.0   Back to index