Unsolved Changing Contents when Slecting other widgets
-
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sysdef foo():
app = QApplication(sys.argv)
window = QWidget()
window.setStyleSheet("""
background-color: green;
""")
btn1 = QPushButton('My_Button', window)
btn1.setStyleSheet("""
QPushButton{
background-color:yellow;
}
""")
btn1.setGeometry(25,25,50,50)
window.resize(100,100)
window.show()
sys.exit(app.exec())
if name == "main":
foo()If i press tab the My_Button is selected, so what i want is when i select a widget it changes content(here QWidget,background) of other widgets
-
Hi,
One possible way to do that is to use a dynamic property that you set when the widget gets/loses focus.
See here for an example of style sheet with dynamic properties.