[英]pyQt Radio Buttons: Adjusting size of buttons and text
我正在嘗試在 PyQt 中調整按鈕的大小和單選按鈕小部件的文本,但都沒有成功。
用這段代碼:
radioButton = QRadioButton(options[x]['desc'])
radioButton.setStyleSheet('font: 16pt Helvetica MS; QRadioButton::indicator { width: 30px; height: 30px;};')
我明白了:
小按鈕,大文字
但是當我這樣做時:
radioButton = QRadioButton(options[x]['desc'])
radioButton.setStyleSheet('QRadioButton::indicator { width: 30px; height: 30px;};')
我明白了:
大按鈕,小文字
那么組合語句以獲得大按鈕/大文本組合的正確方法是什么?
您必須使用{}
'QRadioButton{properties} QRadioButton::indicator{properties};'
例子:
from PyQt5.QtWidgets import *
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
f = QFrame()
f.setLayout(QVBoxLayout())
for i in range(4):
r = QRadioButton("opt{}".format(i), f)
r.setStyleSheet('QRadioButton{font: 30pt Helvetica MS;} QRadioButton::indicator { width: 30px; height: 30px;};')
f.layout().addWidget(r)
f.show()
sys.exit(app.exec_())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.