Home>

How to change this partcheckbox?

self.CB_30min= QCheckBox ("15 mins", self)
self.CB_30min.move (310, 110)
self.CB_30min.resize (91, 31)
  • Answer # 1

    Alternatively:

    import sys
    from PyQt5.Qt import *
    class Example (QWidget):
        def __init __ (self):
            super () .__ init __ ()
            cb= QCheckBox ('Show title', self)
            cb.stateChanged.connect (self.changeTitle)
            vbox= QVBoxLayout (self)
            vbox.addWidget (cb)
        def changeTitle (self, state):
            if state== Qt.Checked:
                self.setWindowTitle ('QtGui.QCheckBox')
            else:
                self.setWindowTitle ('Hrllo Worjd')
    StyleSheet= '' '
    QCheckBox {
        spacing: 5px;
        font-size: 25px;
    }
    QCheckBox :: indicator {
        width: 33px;
        height: 33px;
    }
    '' '
    if __name__== '__main__':
        app= QApplication (sys.argv)
        app.setStyle ("fusion")
        app.setStyleSheet (StyleSheet)
        ex= Example ()
        ex.resize (300, 200)
        ex.show ()
        sys.exit (app.exec_ ())
    
  • Answer # 2
    self.CB_30min= QCheckBox ("15 mins", self)
    self.CB_30min.move (310, 110)
    self.CB_30min.setStyleSheet ("" "QCheckBox :: indicator {
      width: 100px;
      height: 100px;
    } "" ")
    self.CB_30min.resize (91, 31)
    

    I probably did not correctly express my idea. I would like to enlarge the area where the "checkmark" is displayed

    54785122021-09-26 09:59:36
  • Answer # 3

    With

    QCheckBox :: indicator {
      width: 100px;
      height: 100px;
    }
    

    Alexander Chernin throws a syntax error

    54785122021-09-26 09:59:36

    Sorry to 'rewrite' your answer, but mine is clearer.

    Victor VosMottor2021-09-26 09:59:36