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. [SOLVED]textEdit. Different colors for different lines/strings?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]textEdit. Different colors for different lines/strings?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.1k 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.
  • M Offline
    M Offline
    MrNoway
    wrote on 2 Dec 2012, 16:08 last edited by
    #1

    Im just trying to figure out,
    how can i set different colors and different front styles
    for different lines or basically for different strings in QTextEdit or QTextBrowser

    If I use the designer its easy for written text, but without it just cant do it.

    here is what I mean

    http://photouploads.com/images/untitlawa.jpg

    i can change the color for everything
    @ui.textEdit->setTextColor(11000);@

    but this is not what Im looking for.

    has someone an idea?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jake007
      wrote on 2 Dec 2012, 16:24 last edited by
      #2

      Hi!

      Use html for text styling.

      Wrap your text in span and add css style to it.
      example:
      @<span sty le="color: red">Youre text goest here. <b>You can make it bold</b><i> italic</i> or <b><i>both</i></b></span>@

      Use this when using ui->textEdit->append();


      Code is poetry

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MrNoway
        wrote on 2 Dec 2012, 16:44 last edited by
        #3

        hi thanks for your reply but hmm

        after many tries...
        I finally made something, that's almost what I want.

        if you just add html style infront of your text/strings/arrays whasotevever
        it automatically convert it.

        for bold you just have do add @<b></b>@

        @key_storage[10000] = "<b>Film Titel Original: </b> "; @

        and if someone else read my other postings, its working as i want.

        It just little surprise me, that the @"\n" //new line command losts its effect after using one html code@

        so I have to replace that with <br>.

        but okay

        1 Reply Last reply
        0

        1/3

        2 Dec 2012, 16:08

        • Login

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