CharFormat how set backgroud color ??



  • 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.



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



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



  • 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)));

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.