For demonstration I created a simple simple widget in Qt-Creator.
- widget.h
- widget.cpp
- main.cpp
- widget.ui
- I added a QPushButton to Design-Form by drag-and-drop
- Implementing QFont expression to widget.cpp:
// 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; }
- Clicking on "build" and "run" (Play Button) the widget appears with blue Text in Arial, 20, bold widget with blue text:
- But in the Qt GUI design form, the pushButton text is still black and default, does not appear updated gui designer black text:
Is there any way to synchronize the implemented code with the GUI-form?
Like saying to Qt: Update widget.ui according to source code files
A not proper workaround is:
- Only using GUI Designer form (no direct code implementing): Selecting pushButton -> Adjust font Properties in property manager (Qt updates XML file, by markup language)

