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. CharFormat how set backgroud color ??
Forum Updated to NodeBB v4.3 + New Features

CharFormat how set backgroud color ??

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k 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.
  • P Offline
    P Offline
    Pablik2005
    wrote on last edited by
    #1

    hi i use QTextEdit and i want change background color on single char, i know char color can change with change
    [code]
    QTextChaFormat::setTextOutline(QPen(QColor::Color))
    [/code]
    Underline color can change
    [code]
    QTextChaFormat::setUnderlineColor,
    [/code]
    but i can't finde background color.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      absfrm
      wrote on last edited by
      #2

      use this code for change selected char bg color
      @
      ui->textEdit->setTextBackgroundColor(Qt::red);
      @

      If You Want You Can!

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pablik2005
        wrote on last edited by
        #3

        but i neet set background color to single char, not to all TextEdit.
        ok i have , QTextCharForm inherits setBackground(); srry

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vidhya
          wrote on last edited by
          #4

          Then try the following

          @QTextCharFormat format;
          format.setForeground(QBrush(QColor(0,0,0)));
          format.setFontFamily("Times New Roman"); format.setFontPointSize(12);
          format.setFontWeight(QFont::Bold);
          format.setBackground(QBrush(QColor(255,0,0)));

          @

          Regards,
          Vidhya

          1 Reply Last reply
          0

          • Login

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