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

Can I make the QCheckBox label clickable?



  • Normally when creating a QCheckBox with a label, the label does not respond to clicks of the mouse.

    Is there a simple way to let the checkbox respond to clicks on the labels instead of only responding to clicks exactly on the checkbox itself?



  • hI @Jakob

    Have you tried to create an inherited class from QCheckbox, and reimplement the mousePressEvent() Virtual Function?



  • Nevermind - in the end it turned out the label was modeled as a separate QLabel instead of the text of the QCheckBox. Once I removed the label, and put the text inside the checkbox, I got exactly what I was asking for.