[Python] PyQt6 QPushButton:hover not changing background colour

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I have written this code in PyQt6:

    self.button = QPushButton(parent=self, text='Fetch METAR')
    self.button.setStyleSheet("""
    QPushButton {
    color: white;
    background-color: #42baff;
    }
    QPushButton:hover {
    color: white;
    background-color: #3ca8e6;
    }
    """)
    self.button.setFixedSize(QSize(400, 60))
    self.button.move(QPoint(50, 220))


    but for some reason, it doesn't work. The text colour changes, but the background colour of the QPushButton does not change when hovering over it, unless I define any border on QPushButton. When I do, it works normally.

    I tried using PyQt5 to see whether it works there and voila, it does, but I want to use PyQt6.

    Continue reading...

Compartilhe esta Página