I am trying to set the background color for a double spin box, and I am not sure what function I should use.
I saw some function called SetBackgroundRole which accepts a Qt::ColorRole, but I am not sure how to use this one as well.
Kindly let me know, what’s the simple way to change the background color of a QComboBox or QDoubleSpinBox?
Using a
QPaletteisn’t guaranteed to work for all styles, because style authors are restricted by the different platforms’ guidelines and by the native theme engine.To make sure your background color will be correct, I would suggest to use the Qt Style Sheet. Here is what I did to change the background color of a
QComboBox:myComboBox->setStyleSheet('QComboBox { background-color: blue; }');I haven’t specifically tried for a
QSpinBox, but I guess it’ll work the same !