Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. TextEdit Colored Texts or StatusBar Colored Texts
Forum Updated to NodeBB v4.3 + New Features

TextEdit Colored Texts or StatusBar Colored Texts

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 269 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stevendragoes
    wrote on last edited by Stevendragoes
    #1

    Hi, I have the following code to display Red, Green, Blue of a particular pixel in an image.

    ui->textEdit->append(QString("RED = %1, GREEN = %2, BLUE = %3").arg(rgb.red()).arg(rgb.green()).arg(rgb.blue()));
    

    However, the text that came out is a bit ugly.

    How can I set the color? I want to display in TextEdit that I have or the StatusBar of my mainwindow.

    Edit: I want it to be something like this
    cc8f4f67-0126-4678-8fe5-820b8a55df91-image.png

    Gojir4G 1 Reply Last reply
    0
    • S Stevendragoes

      Hi, I have the following code to display Red, Green, Blue of a particular pixel in an image.

      ui->textEdit->append(QString("RED = %1, GREEN = %2, BLUE = %3").arg(rgb.red()).arg(rgb.green()).arg(rgb.blue()));
      

      However, the text that came out is a bit ugly.

      How can I set the color? I want to display in TextEdit that I have or the StatusBar of my mainwindow.

      Edit: I want it to be something like this
      cc8f4f67-0126-4678-8fe5-820b8a55df91-image.png

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Stevendragoes Hi,

      You can use html:

       QString("<font color=\"#FF0000\">RED = %1</font>, <font color=\"#00FF00\">GREEN = %2</font>, <font color=\"#0000FF\">BLUE = %3</font>").arg(rgb.red()).arg(rgb.green()).arg(rgb.blue());
      
      1 Reply Last reply
      5
      • A.A.SEZENA Offline
        A.A.SEZENA Offline
        A.A.SEZEN
        wrote on last edited by A.A.SEZEN
        #3
        QColor rgb;
            ui->textEdit->append(QString("<font color=\"red\">RED, </font>"
                                         "<font color=\"green\">GREEN, </font>"
                                         "<font color=\"blue\">BLUE </font>"));
            ui->textEdit->append(QString("<font color=%1>RED, </font>"
                                         "<font color=%2>GREEN, </font>"
                                         "<font color=%3>BLUE </font>")
                                 .arg(rgb.fromRgb(255,0,0).name())
                                 .arg(rgb.fromRgb(0,255,0).name())
                                 .arg(rgb.fromRgb(0,0,255).name()));
            ui->textEdit->append(QString("<font color=%1>RED, </font>"
                                         "<font color=%2>GREEN, </font>"
                                         "<font color=%3>BLUE </font>")
                                 .arg("#ff0000")
                                 .arg("#00ff00")
                                 .arg("#0000ff"));
        
        
        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved