PDA

View Full Version : How to reset a stylesheet to default?



homerun4711
17th February 2011, 14:50
Hello!

I use a stylesheet to draw a red border around QLineEdits if the QValidator fails. So far this works fine. But I could not figure out how to reset the stylesheet to the default one. The style is returned to its default on a valid input, but not if the field is emptied.

I read somewhere that one could use


lineEdit->setStyleSheet(styleSheet());

but this does not work...

Do you know how I can fix this?

Kind regards,
HomeR

BalaQT
17th February 2011, 15:46
hi,
try
pushButton->setStyleSheet("");

Bala

homerun4711
17th February 2011, 16:25
Thanks for your answer.
As I just found out, both methods work:


lineEdit->setStyleSheet(styleSheet());
and

lineEdit->setStyleSheet("");

But in my case the problem was somewhere else: the styleSheet-reset was overwritten by another setStyleSheet called by a signal-slot connection and thus it not change. *stupid*stupid* :)

Kind regards,
HomeR

BalaQT
19th February 2011, 04:43
hi,
good to hear you solved the problem
:)