A good way to set style for a clicked QPushButton (indicates as active)
-
Hi!
I'm looking for a good solution to set the button's style after clicked (stay after clicked) via QSS. The current solution is setting a new class name via a dynamic property and update the container-widget and the button (via setstyle).
Here's the code so far:
@if (m_ActiveNavigationButton != NULL)
{
m_ActiveNavigationButton->setProperty("isActiveButton", false);
m_ActiveNavigationButton->setStyle(QApplication::style());
m_ActiveNavigationButton = navibutton;
m_ActiveNavigationButton->setProperty("isActiveButton", true);
m_ActiveNavigationButton->setStyle(QApplication::style());
}
else
{
m_ActiveNavigationButton = navibutton;
navibutton->setProperty("isActiveButton", true);
m_ActiveNavigationButton->setStyle(QApplication::style());
}
update();
repaint();@Is there a solution in QSS or is it necessary to update the window in that way? I know that i can use the "pressed-state" in QSS, but it only appears at click and does not stay after click.
Any ideas on that?
Thank you !!
-
Hi,
IIRC you also have to set the style for the checked state
Hope it helps
-
You mean QPushButton::Checked?
-
Rather:
@"QToolButton:enabled:checked"@
-
In addition to above, you also need to set 'setCheckable(true)' property for your PushButton.
-
Thank you for your answers.
I will try it today and give some feedback. Excuse the late answer...i was sick and now i'm back to business.
Have a nice day!