I did a workaround. The idea was make the highlight with the same color of the item.
Connect the highlighted signal from QComboBox:
{
connect( this, SIGNAL(highlighted(int)), this, SLOT(slotHighlight(int)) );
}
ComboBoxColor( QWidget *parent = 0 ) : QComboBox( parent )
{
connect( this, SIGNAL(highlighted(int)), this, SLOT(slotHighlight(int)) );
}
To copy to clipboard, switch view to plain text mode
The slot will set the correct color for the current item:
void ComboBoxColor::slotHighlight(int index)
{
QColor color
(colorNames.
at(index
));
palette.
setColor(QPalette::Highlight, color
);
setPalette(palette);
}
void ComboBoxColor::slotHighlight(int index)
{
const QStringList colorNames = QColor::colorNames();
QColor color(colorNames.at(index));
QPalette palette = this->palette();
palette.setColor(QPalette::Highlight, color);
setPalette(palette);
}
To copy to clipboard, switch view to plain text mode
Bookmarks