Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.1
-
None
Description
When QSS targets the child of a hovered element it always applies the hovered formatting regardless if the element is being hovered or not.
See the example code below.
I would expect the QLabel to be red by default and then when hovered it would be green.
It is always displayed as green regardless of the hover state.
I don't know C++ but here is the Python code using PySide6
import sys from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QFrame Style = """ QFrame > QLabel{ background-color: #FF0000; } QFrame:hover > QLabel{ background-color: #00FF00; } """ def main(): app = QApplication() app.setStyleSheet(Style) window = QWidget() vertical_layout = QVBoxLayout(window) frame = QFrame(window) horizontal_layout = QHBoxLayout(frame) label = QLabel(frame) label.setText("hello") horizontal_layout.addWidget(label) horizontal_layout.addStretch(1) vertical_layout.addWidget(frame) vertical_layout.addStretch(1) window.show() sys.exit(app.exec()) if __name__ == '__main__': main()