为了演示,我在QT-Creator中创建了一个简单的小部件。
// widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{
ui->setupUi(this);
QFont serifFont("Arial", 20, QFont::Bold); // Added QFont expression
ui->pushButton->setFont(serifFont);
ui->pushButton->setStyleSheet("color: blue"); // and text in blue color
}
Widget::~Widget() { delete ui; }
有什么方法可以使实现的代码与GUI表单同步吗?
比如对qt说:根据源代码文件更新widget.ui
不适当的解决办法是:
不,没办法。Qt Designer预览只呈现基于。UI构建的GUI。
Qt Designer是一个单向工具。它不能将您在代码中所做的更改解析回UI设计文件中。