Change hyperlink color in QT

1
2
3
4
5
6
	// ui->btnEdit is a QLabel.
	ui->btnEdit->setText(QString("<a href=\"localhost\"><font color=\"#ff0000\">") + tr("Edit") + QString("</font></a>"));
	ui->btnEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
	connect(ui->btnEdit, &QLabel::linkActivated, [=, this](QString url) {
		...
	});

refer to:
https://www.lmlphp.com/user/507/article/item/13949