Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTextEdit - unable to modify base color



  • Hi All,

    I've a QTextEdit called secondsText, I need to change the base color, so I tried as follows in the constructor, which doesn't work:

    QPalette p = ui->secondsText->palette();
    p.setColor(QPalette::Base, Qt::green);
    ui->secondsText->setPalette(p);
    

    Base color is still the default (white), what might be the issue?



  • @viniltc said in QTextEdit - unable to modify base color:

    • Test against QPalette::Text, to verify whether that works on foreground, just so you know.
    • If you have any stylesheet background-color specified, including back up the hierarchy I think, that will override.

Log in to reply