I have a QLineEdit
and i have set an image to QStackedWidget
. Now i want to change the font color of Texts which is in QLineEdit
. How to do it?
QLineEdit *line1 = new QLineEdit("Hello");
QStackedWidget *stack1 = new QStackedWidget();
stack1->addWidget(line1);
stack1->setStyleSheet("background-image: url(black.gif);");
I tried writing foreground-color
and foreground
in setStyleSheet.
But its not work for me.
This worked for me :
QPalette *palette = new QPalette();
palette->setColor(QPalette::Text,Qt::red);
line->setPalette(*palette);
Normally, this can be achieved by setting the color stylesheet property, so no foreground-color or something like that. So this should do it:
QLineEdit *line1 = new QLineEdit("Hello");
QStackedWidget *stack1 = new QStackedWidget();
stack1->addWidget(line1);
stack1->setStyleSheet("background-image: url(black.gif); color: #FFFFFF");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With