How to add an Error image in QLineEdit when the Input Text is Invalid ?
I have a QLineEdit in that I have setted the Maximum value as 1000. Suppose if I Enter 125436 as input text then i have to add an error image at the right corner of the QLineEdit indicating that the entered text is InValid.. I tried using Stylesheets,
but it doesn't work.. please post your suggestions...
Thanks & Regards...
Check the solutions provided at similar threads:
- "The background-color of the QLineEdit":http://qt-project.org/forums/viewthread/2640
- "Background-image for QLineEdit":http://stackoverflow.com/questions/7324857/background-image-for-qlineedit
Thanks for your sggestion leon.anavi...
Already I checked that similar threads and tried.. Eventhough it is not working.. :(
If your input are only numbers, why not use a QSpinBox ?
Yeah i can make use of a Spin Box... but that is not my Requirement... My requirement is to add an image in the QLineEdit when the input is invalid...
[quote author="Rochi" date="1363090439"]Thanks for your sggestion leon.anavi...
Already I checked that similar threads and tried.. Eventhough it is not working.. :([/quote]
According to the thread fro stackoverflow.com it will not work without:
@border: 1px solid #000000;@
Have you tried to append it to the style?
[quote author="SGaist" date="1363090779"]If your input are only numbers, why not use a QSpinBox ?[/quote]
Honestly if I was implementing this solution instead of setting the background I would just place an label with an image on the right side of the input box and display it only when it is needed :)
You could adapt the "example":http://blog.qt.digia.com/blog/2007/06/06/lineedit-with-a-clear-button/ floating about on the net on how to add a clear button to a line edit. Only, you don't need a button, but a label with a small image on it.
Here's my qss code...
border-style: solid; border: 2px solid red; color: red; border-radius: 8px; background-image: url(:/resources/Error.png); background-color: yellow; background-repeat: no-repeat; background-position: right;
Also i tried using the background-position.. But No use....
I've checked your code and it shows the image in my test. The only thing I can think of is maybe your resource image can't be found for any reason? Have you checked it anywhere else?