David Ludwig David Ludwig - 1 year ago 334
C++ Question

Qt Set Background Color of QLineEdit

I'm trying to change the background color of the

and I can't figure it out at all.

I tried using
originally like this

QLineEdit *le = new QLineEdit();

but that didn't do anything. I tried using
like this

QPalette palette;
palette.setColor(QPalette::Base, Qt::black);
palette.setColor(QPalette::Background, Qt::black);

but this didn't do anything either. I've been looking all day and can't find anything. am I doing something wrong or is there another way to do it?

Answer Source

Works fine for me:

QLineEdit *le = new QLineEdit();
le->setStyleSheet("QLineEdit { background: rgb(0, 255, 255); selection-background-color: rgb(233, 99, 0); }");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download