'PyQt5 Resize QCheckbox Bug?

I am currently trying to resize a QCheckbox in order to make it a little bit larger. However, I am facing a weird problem as the text next to the Checkbox gets larger, but the box itself stays the same size. I copied this code here from this tutorial and it seems to work in the corresponding video that is found on the website.

import sys      
from PyQt5.QtWidgets import QApplication, QWidget, QCheckBox, QHBoxLayout

class AppDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(400, 200)

        layout = QHBoxLayout()  

        self.setStyleSheet("""
          QCheckBox {
              font-size: 50px;
          }
          QCheckBox::indicator {
              width: 50px;
              height: 50px;               
          }
        """)

        self.checkBoxYes = QCheckBox('Yes') 
        layout.addWidget(self.checkBoxYes)

        self.checkBoxNo = QCheckBox('No')
        layout.addWidget(self.checkBoxNo)

        self.setLayout(layout)
                

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(True)
    demo = AppDemo()
    demo.show()
    
    try:
        sys.exit(app.exec_())
    except SystemExit:
        print('Closing Window...')

However, when executing the code, I get the following result:

checkbox result

The hitbox of the checkbox increased but the checkbox itself stayed the same size - did I miss something? Does it work for you guys and if so, which version of PyQt5 are you using?

I have the following PyQt5 versions:

PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.1

Edit: I found that I can change the style:

app.setStyle("Fusion")

and then the checkbox resizes properly. However, is there maybe any other way to fix this in the default style?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source