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: 129

Filed under:
|
|

I've managed to style my QLineEdit to something like this:

alt text

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:

  1. User open form
  2. User fill data
  3. User submit data
  4. Got error
  5. Use setFormErrorStyle()
  6. 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

Related posts about qt

Related posts about stylesheet