'How to get the color of a widget text, and set it as the color of another widget

I have two widgets

first, a QLineEdit that has a stylesheet (assume not accessible or changeable) that sets the color of the text to some color (e.g., red).

second, QLabel that has a default text color (e.g., black)

How can I get the color of the text in the QLineEdit, and set it as the color in the QLabel

l1 = QLineEdit()
color_to_be_set= l1.palette().highlight().color().name() # this approach is giving the wrong color

q1 = QLabel()
q1.setText("the text")

# then set the new color
"Trial#1 (Not working at all, not changing the color)"
palette = q1.palette()
palette.setColor(QPalette.WindowText,QColor(color_to_be_set))
q1.setPalette.....

"Trial#2, gives the wrong color"
q1.setStyleSheet("color:{}".format(color_to_be_set))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source