#include#include QLabel *label = new QLabel("Hello World"); QFont font = label->font(); font.setWeight(QFont::Bold); label->setFont(font);
#includeIn this example, we create a new QTextEdit widget and define a custom font weight by setting the weight value to 80. This corresponds to a bold weight that is slightly lighter than the predefined QFont::Black constant. We then apply the modified font to the text edit widget using the setFont method. Package library: Qt#include QTextEdit *textEdit = new QTextEdit(); QFont font("Arial", 12); font.setWeight(80); textEdit->setFont(font);