1.设置标题*

在widget.cpp文件下的
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget){ }
这个函数中加上setWindowTitle(“标题”);
如:把标题设为计算器
setWindowTitle(“计算器”);

**

2.设置窗体背景颜色

**
在同样的函数中加上
this->setStyleSheet(“background-color:颜色;”);
this->show();

如:要把背景设为粉色
this->setStyleSheet(“background-color:pink;”);
this->show();

如下是我的代码:

 Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);
    setWindowTitle("计算器");
    this->setStyleSheet("background-color:pink;");
    this->show();
    }
       

计算器程序是提前写好的
如下是运行结果:
QT设置窗体标题及背景颜色

相关文章:

  • 2021-07-07
  • 2021-08-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-02-10
  • 2022-02-02
  • 2022-01-19
  • 2021-06-28
相关资源
相似解决方案