Search code examples
pythonqtpyqtpysidemaya

(pyQt/pySide)setStyleSheet(border....) makes QPushButton not clickable in Maya


guys. Trying to learn PyQt inside Maya and I am facing little problem which is more of discomfort then a problem. When I set border for my button :

button.setStyleSheet('
 background-color: rgb(120, 120, 100);
 color:rgb(1, 255, 255);
 border: none')

My button is still working , but visually it's not clickable , if you click on button it's being static. Anybody faced that problem and knows how to solve ? Any help will really appreciate.

Thanks!


Solution

  • Have a look at the Qt Style Sheet documentation here.

    You can use the pseudo-states hover, checked, pressed, to change the look and feel of your button under these circumnstances.

    As an example, you can make the background darker when the button is pressed with:

    QPushButton:pressed { background-color: rgb(80, 80, 60); }
    

    Otherwise, your button will always look the same no matter if it is pressed or not.