This sounds like good idea, but I don't completly unterstand what you mean.

In my case, the code I posted above is from a separate function validateData(), which is called before the data from a form is inserted into a database. If the validation fails, message boxes pop up or a border around Qlineedits are drawn to signal where the problem lies. Do you mean something like this?