In KDE every line edit has a clear button that appears when there is text.

How do I do that? Preferably something that doesn't require KDE.