Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Regarding Stylesheet



  • Hi...
    I am implementing customized radiobutton, there i am setting stylesheet to radiobutton like this,
    setStyleSheet("QRadioButton::indicator::hover {width: 30px;height: 30px;};");

    this works fine when i hover on button but along with this i need to set one more style that is i need to increase size of button when button not hovered.. for this how can i set?

    Thanks.


  • Moderators

    @Venkatesh-V

    radioButton->setStyleSheet(
    "QRadioButton::indicator {width: 32px;height: 32px;};"
    "QRadioButton::indicator:hover {width: 30px;height: 30px;};"
    );
    


  • Here is the Qt stylesheet guide. You can find additional options for the radio button, but if I understand you correctly this is what you're asking for:

    setStyleSheet("QRadioButton::indicator:hover { width: 30px; height: 30px;}; QRadioButton::indicator { width: 15px; height: 15px; };");
    

    Just concatenate the next style in the same stylesheet string.

    Edit: Fixed scope resolution operators.



  • Thanks @raven-worx ...
    thanks @Carmoneer ...

    i have tried this... but i'm not getting both properties.. only first one i got.... if i give hover property first and then another hover only comes... what can i do for this...

    Thanks.


  • Moderators

    @Venkatesh-V said in Regarding Stylesheet:

    i have tried this... but i'm not getting both properties.. only first one i got.... if i give hover property first and then another hover only comes... what can i do for this...

    sorry, but i don't understand what you wrote.



  • Hi @raven-worx

    my .cpp file like this bellow

    MyRadioButton::MyRadioButton(QString RadioButtonText, QWidget *parent) : QRadioButton(RadioButtonText,parent)
    {
    this->setStyleSheet("QRadioButton::indicator:hover { width: 30px; height: 30px;}; QRadioButton::indicator { width: 25px; height: 25px; };");

    }

    for this i am able to changing my radiobutton size when i hover on it.. before hover on it the size is remains default size.. i need that size as 25px... only first style works here.. not second one.

    Thanks.


Log in to reply