How to set icon at different modes?

  • Hi,

    I try to change the image of a qpushbutton in disabled mode
    This is just editing the Normal mode.


    [edit:syntax hihlight added / Denis Kormalev]

  • You should create QIcon object and set additional pixmap for QIcon::Mode==Disabled

  • You can use style sheet:
    QPushButton {
    border-image: url(:/images/bouton-retour.png);
    background-color: rgba(255, 255, 255, 0);

    QPushButton::pressed,QPushButton:disabled {
    border-image: url(:/images/bouton-retour-desactive.png);

    [edit: fixed code / chetankjain]

  • cheng, border-image is not exactly what needed for author. It will fill borders, but not change icon.

Log in to reply