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

QPushButton pressed.



  • Hi to everyone, I put some buttons in Qt Creator, but I would like that when I pressed it, this become with some oppacity so, the user can see which button he has pressed.

    I put this in the "Change styleSheet" part:

    #buenaVal{
    background-color:transparent;
    border-image: url(:/HappyFace.png);
    background: none;
    border:none;
    background-repeat: none;
    }
    #buenaVal:pressed{
    background-color:transparent;
    border-image: url(:/HappyFace.png);
    background: none;
    border:none;
    background-repeat: none;
    opacity:0.5
    }

    but it doesn't work...
    Could someone help me, please?
    thank youuu!



  • Hi,
    you can probably use a PNG image that is half transparent for the pressed button.
    -Michael.



  • I do not understand very clearly the goal you want to achieve. If you just want to apply a style on the #buenaVal between the moment the user presses the button and until he releases it, then I think the code above should work.

    But, if you want to apply the style even if the the user has released the mouse, so the :checked pseudo state should be used instead of :pressed.

    Note : You do not have to repeat a style if it does not changes. I think that only the opacity property must be set.



  • Thank you a lot, I did!



  • Happy that it helped! You should mark the subject as solved.


Log in to reply