PDA

View Full Version : QPushButton::setDown() doesn't stay down



Cruz
24th February 2009, 16:45
Hello.

Sometimes I would like to programmatically set a button down and keep it in a pushed state. This has no other than visual reasons, it shows that there is a process running that can be stopped by the same button that started it.

I just discovered that it actually doesn't work.



void MyWidget::on_Button_clicked()
{
if (ui.Button->isDown())
return;

ui.Button->setDown(true);
}


After I click the button, it stays down like it should. But when the button loses focus, it comes back up. Another thing is that despite the check if the button is down already, wild clicking can also bring it back up again. Is there anything I can do about this? I know I could disable a button instead of downing it, but I'm already using that for when a button should be really disabled.

talk2amulya
24th February 2009, 16:51
would setCheckable() work for you..it will make the button toggle..so when u click, it'll stay in down state until u click it again or emit clicked() urself

Cruz
24th February 2009, 17:09
Thanks mate! It works totally awesome.