Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Button display problem



  • Hello,

    I'm building an application with PyQt5 on Windows and I have a problem with button display. When I click on a button, I disabled it with the method : setEnabled(False)

    The desired result is : button.gif

    However, sometimes, the display does not work and the button remains blue, as if the animation was interrupted : error_button.gif

    Do you know what the problem is and how I can fix it?



  • Could be a timing problem since the disabling is happening during the press.
    try to not call setEnabled directly from the slot that is called on click, but with delay

    QTimer::singleShot(0, this, SLOT(disableButton());
    

    where disableButton() is a slot that calls setEnabled(false) on the button.



  • @gde23

    I chose a time of 300ms and it's working well.
    Thanks for your help.


Log in to reply