#include#include int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel label("Hello, world!"); QFont serifFont("Times", 12, QFont::Bold); label.setFont(serifFont); label.show(); return app.exec(); }
QFont font = label.font(); font.setFamily("Helvetica"); font.setPointSize(16); label.setFont(font);In this example, we retrieve the current font of an existing label, modify its family and size, and set it back to the label. Package library: Qt