[Solved]select effect in pushbuttons
-
wrote on 20 Jul 2011, 06:57 last edited by
:)
i come again with yet another button problem. Ive created an array of buttons with out using the designer.@cellBut[i][j]=new QPushButton();
connect(cellBut[i][j],SIGNAL(clicked()),this,SLOT(onClickAction()));@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
-
wrote on 20 Jul 2011, 09:40 last edited by
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.
-
wrote on 20 Jul 2011, 11:38 last edited by
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
-
wrote on 20 Jul 2011, 12:02 last edited by
See QAbstractPushButton::setChecked().
-
wrote on 10 Aug 2011, 06:12 last edited by
The select effect can be done either putting images for the pressed and not pressed state.
So set the stylesheet to suit your needs.Ex:
@QPushButton#settingBut { color: rgb(0, 0, 0);
border-width: 1px; border-radius: 10px; font: bold 20px; min-width: 8em; padding: 5px;
}
QPushButton#settingBut:pressed
{
border-style:solid;
border-width:2px;
}
@