QListWidgetItem* item = new QListWidgetItem("Item Text"); item->setForeground(QColor(Qt::black));
QListWidgetItem* item = new QListWidgetItem("Item Text"); item->setForeground(QColor(Qt::red));In this example, a new QListWidgetItem is created and its foreground color is set to red using setForeground function. Both examples use the QListWidgetItem class from the Qt library and the QColor class to set the foreground color. The Qt library provides many other classes and functions to build GUI applications in C++.