PDA

View Full Version : Underline contents of a QLineEdit on the UI



dennisvz
28th October 2019, 20:43
I have the following line of code that shows what the user entered into a QLineEdit. In certain circumstances, I want to underline the formatted number:



self.ui.car1.setText("${:,}".format(self.car1))


Any way to change the above code to make it underline?

NOTE: I do NOT want to underline the line edit with a border across the bottom of the entire line edit. Nor do I want to underline the contents of the line edit using the QT Designer (because I only want to underline the number in certain circumstances).

thanks

dennisvz
28th October 2019, 23:31
Resolved. I found out that it is not possible to do what I want in the manner I want. There is a workaround, but it will not fit my needs. thanks

d_stranz
28th October 2019, 23:41
Any way to change the above code to make it underline?

Don't think it is possible. If QLineEdit supported rich text format, you could set the text to an RTF string with the underline HTML. But it doesn't support rich text.

The closest you can get is to use QTextEdit, which does support RTF, but also has individual methods to set bold, underline, etc. But QTextEdit comes with a lot of overhead.