Results 1 to 3 of 3

Thread: Underline contents of a QLineEdit on the UI

  1. #1
    Join Date
    Jan 2017
    Posts
    50
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Underline contents of a QLineEdit on the UI

    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:

    Qt Code:
    1. self.ui.car1.setText("${:,}".format(self.car1))
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2017
    Posts
    50
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Underline contents of a QLineEdit on the UI

    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

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,644
    Thanks
    256
    Thanked 739 Times in 729 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Underline contents of a QLineEdit on the UI

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 0
    Last Post: 19th February 2013, 23:23
  2. Replies: 2
    Last Post: 28th October 2011, 06:46
  3. To underline the numbers behind the decimal points?
    By wookoon in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2010, 23:01
  4. Turn off the underline when using a QLabel as a link
    By gmat4321 in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2010, 13:31
  5. Replies: 0
    Last Post: 18th March 2009, 06:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.