July 17, 2012

Pablik2005 Pablik2005
Lab Rat
33 posts

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

  1. QTextChaFormat::setTextOutline(QPen(QColor::Color))

Underline color can change
  1. QTextChaFormat::setUnderlineColor,

but i can’t finde background color.

3 replies

July 17, 2012

abbas farahmand abbas farahmand
Dinosaur Breeder
373 posts

use this code for change selected char bg color

  1.     ui->textEdit->setTextBackgroundColor(Qt::red);

 Signature 

If You Want You Can!

July 20, 2012

Pablik2005 Pablik2005
Lab Rat
33 posts

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

July 25, 2012

Vidhya Vidhya
Ant Farmer
48 posts

Then try the following

  1. format.setForeground(QBrush(QColor(0,0,0)));
  2. format.setFontFamily("Times New Roman");     format.setFontPointSize(12);
  3. format.setFontWeight(QFont::Bold);
  4. format.setBackground(QBrush(QColor(255,0,0)));

 Signature 

Regards,
Vidhya

 
  ‹‹ Updating QScrollArea scroll bars in code - verticalScrollBar()->value() always returns 0 whatever value it is given      QAction Disabled in a Toolbar can not be Checked? ››

You must log in to post a reply. Not a member yet? Register here!