QToolButton that works as a QCheckBox



  • Hello,

    I would like to make three QCheckBoxes, each one having its own picture when it's checked and when it's unchecked. I found this on Google but that seems to make all QCheckBoxes work with the same pictures. How can I fix that? Must I use style sheets to accomplish this anyway?

    Not sure if this information is useful, but these QCheckBoxes would be clickable inside a QGraphicsView/QGraphicsScene system. Not inside a simple QMainWindow.

    Thanks a lot for your input!


  • Moderators

    @Pippin
    QToolButtons support images/icons and can also be set checkable.
    If you want them mutual exclusive you can put them into a QButtonGroup.

    Alternatively you can try to do that:

    QCheckBox#MyObjectName::indicator:checked {
       ...
    }
    

    But i guess this won't be accepted by the QSS parser.
    As a workaround you can wrap each checkbox around a container widget and set the object name on it.

    QWidget#MyObjectName > QCheckBox::indicator:checked {
       ...
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.