Resetting Qt Style Sheet
Posted
by mree
on Stack Overflow
See other posts from Stack Overflow
or by mree
Published on 2010-06-16T11:14:49Z
Indexed on
2010/06/16
11:52 UTC
Read the original article
Hit count: 149
I've managed to style my QLineEdit to something like this:
void Utilities::setFormErrorStyle(QLineEdit *lineEdit)
{
lineEdit->setStyleSheet(
"background-color: #FF8A8A;"
"background-image: url(:/resources/warning.png);"
"background-position: right center;"
"background-repeat: no-repeat;"
"");
}
I called the function using
Utilities *util = new Utilities;
util->setFormErrorStyle(lineNoStaf);
The flow should be something like this:
- User open form
- User fill data
- User submit data
- Got error
- Use
setFormErrorStyle()
- User edit the text in the QLineEdit and the style disappear
This function should be reusable over and over again, but how can I connect QLineEdit signal such as textChanged()
to a function in other class that will reset the Style Sheet and then disconnect the signal so that it won't be running continuously every time the text changed ?
© Stack Overflow or respective owner