QColorPicker with bright slider

886 Views Asked by At

When I open a QColorPicker, I click in the coloor map in the top center, and select any color (lets say red) this color appears as black in the selected color bar bottom center.

I have to move additionally the slider on the top right (see red arrow) enter image description here to its top position, to approach the selected color. Why is this slider not initially set to the highest value, so I do not see black always?

1

There are 1 best solutions below

0
On BEST ANSWER

In the documentation it refers to the Standard Dialogs example:

void Dialog::setColor()
{
    const QColorDialog::ColorDialogOptions options = QFlag(colorDialogOptionsWidget->value());
    const QColor color = QColorDialog::getColor(Qt::green, this, "Select Color", options);

    if (color.isValid()) {
        colorLabel->setText(color.name());
        colorLabel->setPalette(QPalette(color));
        colorLabel->setAutoFillBackground(true);
    }
}

Note in QColorDialog::getColor how it specifies an initial color. This should set the brightness bar for you.

http://doc.qt.io/qt-5/qcolordialog.html#getColor

QColor QColorDialog::getColor(const QColor & initial = Qt::white, QWidget * parent = 0, const QString & title = QString(), ColorDialogOptions options = 0)

Hope that helps.