最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why can't one change the size of a PyQt checkbox? - Stack Overflow

programmeradmin2浏览0评论

The following code runs, but the checkbox is tiny (it should be large). Why doesn't this work as expected? (One can use styling to resize the text, but that's not what I'm trying to do here). I'll be grateful for any suggestions.

import sys

from PyQt5.QtWidgets import (
    QApplication,
    QCheckBox,
    QVBoxLayout,
    QWidget,
)

class Window(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

        # Create a Checkbox with a text label:
        chkBox = QCheckBox(text="Check box if you want this option.")

        # Make the checkbox large (has no effect):
        chkBox.setStyleSheet('QCheckBox::indicator {width:24px; height:24px}')

        layout= QVBoxLayout()
        layout.addWidget(chkBox)
        self.setLayout(layout)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec())
发布评论

评论列表(0)

  1. 暂无评论