说明
只涉及设置文本的颜色和背景颜色,表格的单元格颜色属于表格属性编辑不在此范畴内。
效果展示
程序
设置文字的颜色
void TextEditor::textColor()
{
QColor c =QColorDialog::getColor(Qt::black, this );//调用颜色对话框
if ( c.isValid() )
{
QTextCharFormat fmt;
fmt.setForeground( c );
mergeformat( fmt );
}
}
设置文字的背景颜色
void TextEditor::on_action_BackgroundColor_triggered() //用于设置字符的背景颜色
{
QColor c =QColorDialog::getColor(QColor(200,200,200), this );
if ( c.isValid() )
{
QTextCharFormat fmt;
fmt.setBackground©;
mergeformat( fmt );
}
}
最后
这部分的功能比较简单,再次仅做一个记录。