Qt QPlainTextEdit背景 [英] Qt QPlainTextEdit background

查看:1478
本文介绍了Qt QPlainTextEdit背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改 QPlainTextEdit 的背景颜色,我该如何做?

I want to change the background color of a QPlainTextEdit, how do I do this?

推荐答案

修改纯文本编辑的调色板。示例程序:

Modify the palette of your plain text edit. Sample program:

#include <QApplication>
#include <QPlainTextEdit>

int main(int argc, char* argv[])
{
  QApplication app(argc, argv);

  QPlainTextEdit edit;
  QPalette p = edit.palette();

  p.setColor(QPalette::Active, QPalette::Base, Qt::red);
  p.setColor(QPalette::Inactive, QPalette::Base, Qt::red);

  edit.setPalette(p);

  edit.show();
  return app.exec();
}

当然可以替换任何你想要的颜色。

Substitute whatever color you want, of course.

这篇关于Qt QPlainTextEdit背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆