QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText(0, "Item"); item->setTextColor(0, Qt::red);
for (int i = 0; i < treeWidget->topLevelItemCount(); i++) { QTreeWidgetItem* item = treeWidget->topLevelItem(i); item->setTextColor(0, Qt::blue); }This code sets the foreground text color of all top-level items in a tree widget to blue. `QTreeWidgetItem` is part of the Qt Widgets package, so to use this function, you would need to include the `QtWidgets` library in your project.