<p>What is the best way to give the user feedback for a color selection?<br>
I have a dialog with a "Select Color" push button which pops a <code>QColorDialog</code>. After the selection is made I want to show the user the color selected.<br>
Usually I do this using a <code>QLabel</code> and changing it's background color in the palette. This method is cumbersome and I think not very portable. </p>

<p>Is there a standard way of doing this?</p>

The way I'm doing it is the following :
I actually change the color of the button, to reflect the user choice. To do this, I'm using the Qt style sheet, which ensure it is portable :
```
```
const QString COLOR_STYLE("QPushButton { background-color : %1; color : %2; }");

QColor ChosenColor; // Color chosen by the user with QColorDialog
QColor IdealTextColor = getIdealTextColor(ChosenColor);
btnChooseColor->setStyleSheet(COLOR_STYLE.arg(ChosenColor.name()).arg(IdealTextColor.name()));
```
```
To make sure the label of the button is always readable, I'm calling the method getIdealTextColor(), which is a method I've found from a codeproject article :
```
```
//==============================================================================
//  Nom : getIdealTextColor
//! @return an ideal label color, based on the given background color.
//! Based on http://www.codeproject.com/cs/media/IdealTextColor.asp
//==============================================================================
QColor JSPreferencesDlg::getIdealTextColor(const QColor& rBackgroundColor) const
{
    const int THRESHOLD = 105;
    int BackgroundDelta = (rBackgroundColor.red() * 0.299) + (rBackgroundColor.green() * 0.587) + (rBackgroundColor.blue() * 0.114);
    return QColor((255- BackgroundDelta < THRESHOLD) ? Qt::black : Qt::white);
}
```
```