QWidget* widget = new QWidget(); QPalette palette = widget->palette(); palette.setBrush(QPalette::HighlightedText, Qt::red); widget->setPalette(palette);
QTextEdit* textEdit = new QTextEdit(); QPalette palette = textEdit->palette(); palette.setColor(QPalette::HighlightedText, Qt::yellow); textEdit->setPalette(palette);In this example, we create a new QTextEdit and get its palette using the `palette()` method. Then, we set the highlight text color as yellow using the `setColor()` method and set the palette for the QTextEdit using the `setPalette()` method. These examples make use of the Qt framework, a popular C++ application development framework. Therefore, the package library for QPalette would be Qt.