开发者

select effect in pushbuttons

开发者 https://www.devze.com 2023-03-21 09:23 出处:网络
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()));

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 backgroundt开发者_StackOverflowhing 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


Use the setCheckable() function.

setCheckable(true);

The button will stay checked until clicked again.

Edit: Sorry, I misunderstood your question.

I think you can change the background color of the button, and simulate the highlight effect, with something like:

button->setStyleSheet("background: red");


I think you would like to use a Button group. From the documentation: An exclusive button group switches off all checkable (toggle) buttons except the one that was clicked.

0

精彩评论

暂无评论...
验证码 换一张
取 消