Results 1 to 3 of 3

Thread: Show variable in color on UI

  1. #1
    Join Date
    Jan 2017
    Posts
    54
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Show variable in color on UI

    I would like to show the value of the variable "filestatus" in the following line of code in blue. How?

    Qt Code:
    1. self.ui.title.setText(str("My Tax Info Based on a Filing Status of: " + filestatus))
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Show variable in color on UI

    If "title" is a QLabel, you can format your string in Rich Text Format (RTF) using the subset of HTML supported by the rich text engine.

    Qt Code:
    1. self.ui.title.setText(str("My Tax Info Based on a Filing Status of: <font color=blue>" + filestatus + "</font>" ))
    To copy to clipboard, switch view to plain text mode 
    <=== 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.

  3. #3
    Join Date
    Jan 2017
    Posts
    54
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Show variable in color on UI

    Quote Originally Posted by d_stranz View Post
    If "title" is a QLabel, you can format your string in Rich Text Format (RTF) using the subset of HTML supported by the rich text engine.

    Qt Code:
    1. self.ui.title.setText(str("My Tax Info Based on a Filing Status of: <font color=blue>" + filestatus + "</font>" ))
    To copy to clipboard, switch view to plain text mode 
    perfect, thanks

Similar Threads

  1. How to show the value of stored session variable in MySQL from qt?
    By Ahmed Abdellatif in forum Qt Programming
    Replies: 0
    Last Post: 5th May 2018, 14:39
  2. Replies: 2
    Last Post: 20th October 2017, 00:25
  3. Time Delay for show Color in PushButton
    By yrandom in forum Newbie
    Replies: 1
    Last Post: 28th April 2017, 19:22
  4. Variable variable names
    By KeineAhnung in forum Newbie
    Replies: 2
    Last Post: 22nd June 2014, 20:00
  5. Replies: 0
    Last Post: 31st August 2010, 07:11

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.