@mrjj Thanks, it seems like odd behaviour. So, it uses its native palette, i.e. the palette set either directly or inherited from its parent. I am able to change the colour now, but I am using a C-Style cast, and that's why I am not sure if I should do it. Here is my solution:
void GuiStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
{
if(vars[id].customTheme) {
if(element == QStyle::PE_PanelLineEdit) {
const QStyleOptionFrame* comboOption = qstyleoption_cast<const QStyleOptionFrame*>(option);
QStyleOptionFrame newComboOption = *comboOption;
newComboOption.palette.setBrush(QPalette::Base, Qt::red);
// I am using C-Style cast to get the widget in a non-const pointer and then it's palette again the same way
QLineEdit* lineEditPtr = (QLineEdit*)widget;
QPalette pal = (QPalette)lineEditPtr->palette();
pal.setColor(QPalette::Text, Qt::green);
lineEditPtr->setPalette(pal);
QProxyStyle::drawPrimitive(element, &newComboOption, painter, widget);
}
}
else {
QProxyStyle::drawPrimitive(element, option, painter, widget);
}
}