The setFont method in the QTreeWidgetItem class allows us to change the font style and size of the text displayed in the tree item. This method takes a QFont object as a parameter.
In this example, we create a new tree item "item1" with the text "Item 1". We then create a QFont object "font" with the font family "Arial", font size "12" and bold style, and set this font to the first column of "item1".
Example 2:
QTreeWidgetItem *item2 = new QTreeWidgetItem(); item2->setText(0, "Item 2"); QFont font = item2->font(0); font.setItalic(true); item2->setFont(0, font);
In this example, we create a new tree item "item2" with the text "Item 2". We retrieve the font of the first column of "item2" using the font() method and store it in a QFont object "font". We then modify the font to set the italic style and set it back to the first column of "item2" using setFont() method.
These code examples are written in C++ programming language using Qt framework. Therefore, the package library used is Qt library.
C++ (Cpp) QTreeWidgetItem::setFont - 30 examples found. These are the top rated real world C++ (Cpp) examples of QTreeWidgetItem::setFont extracted from open source projects. You can rate examples to help us improve the quality of examples.