5478512 Asked:2020-01-21 00:02:06 +0000 UTC2020-01-21 00:02:06 +0000 UTC 2020-01-21 00:02:06 +0000 UTC 如何调整 QCheckBox 的大小? 772 我怎样才能改变这部分checkbox? self.CB_30min = QCheckBox("15 мин", self) self.CB_30min.move(310, 110) self.CB_30min.resize(91, 31) python 3 个回答 Voted USERNAME GOES HERE 2020-01-21T00:36:45Z2020-01-21T00:36:45Z self.CB_30min = QCheckBox("15 мин", self) self.CB_30min.move(310, 110) self.CB_30min.setStyleSheet("""QCheckBox::indicator { width: 100px; height: 100px; }""") self.CB_30min.resize(91, 31) Best Answer S. Nick 2020-01-21T01:05:09Z2020-01-21T01:05:09Z 作为一种选择: 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_()) Alexander Chernin 2020-01-21T00:16:07Z2020-01-21T00:16:07Z 使用Qt 样式表 QCheckBox::indicator { width: 100px; height: 100px; }
作为一种选择:
使用Qt 样式表