pyqt5 как сделать псевдокласс
Как сделать чтобы при наведении на self.wordButton изменялся цвет фона и тд.? Типа self.wordButton:hover{}
self.wordButton.setStyleSheet("""
font-size: 15px;
border-radius: 15px;
min-height: 40px;
max-height: 40px;
min-width: 100px;
max-width: 50px;
background-color: #ADD8E6;
border: 1px double #90EE90;
""")
Ответы (1 шт):
Автор решения: gil9red
→ Ссылка
Нужно вам задать цвет при событии hover при разном состоянии pressed (подробнее):
QPushButton:hover:pressedQPushButton:hover:!pressed
Пример:
from PyQt5.QtWidgets import QApplication, QPushButton
app = QApplication([])
pb = QPushButton('Click me!')
pb.setStyleSheet("""
QPushButton {
font-size: 15px;
border-radius: 15px;
min-height: 40px;
max-height: 40px;
min-width: 100px;
max-width: 50px;
background-color: #ADD8E6;
border: 1px double #90EE90;
}
QPushButton:hover:pressed {
background-color: green;
}
QPushButton:hover:!pressed {
background-color: yellow;
}
""")
pb.show()
app.exec()