简体   繁体   中英

QColorPicker with bright slider

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) 在此处输入图片说明 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM