Important: Please read the Qt Code of Conduct -

[Solved]select effect in pushbuttons

  • :)
    i come again with yet another button problem. Ive created an array of buttons with out using the designer.

    @cellBut[i][j]=new QPushButton();

    these are arranged in rows , a calender sorta thing, and i want to select them when clicked once, jus to know tht ive clicked that particular date. It gives the default "pressed and released effect" but not the highlighted effect.

    I want it do the highlighting jus like how the default calenderwidget does.

    is there some highlight function thing. I found an autofill backgroundthing or setMask, but it does nothing, or i dont know how to use it.
    or if i get a pointer of the selected date, does it have the function to select???

    Guide me on this please

    Thank you

  • Did you setCheckable(true)? If you didn't, do it. After that, you can probably change the style sheet to show some differing background color when the button is pressed.

  • thanks franzk

    can we uncheck it programatically. Meaning setCheckable(true) wil check it once clicked right. but even if i click the next button, both the currently clicked and previously clicked are checked :)

    jus like minesweepers :) i don want tht. i want to uncheck the previously clicked one.

    thank you

  • See QAbstractPushButton::setChecked().

  • The select effect can be done either putting images for the pressed and not pressed state.
    So set the stylesheet to suit your needs.


    QPushButton#settingBut { color: rgb(0, 0, 0);

     border-width: 1px;
     border-radius: 10px;
     font: bold 20px;
     min-width: 8em;
     padding: 5px;



Log in to reply