QRadioButton { text-align: center; 没效
时间: 2024-05-10 09:14:18 浏览: 181
如果你想在QRadioButtons上居中文本,你可以使用CSS样式表来实现。以下是一个例子:
```python
radio_button.setStyleSheet("QRadioButton::indicator { width: 20px; height: 20px; } \
QRadioButton::indicator::unchecked { \
image:url('unchecked.png'); \
} \
QRadioButton::indicator::checked { \
image:url('checked.png'); \
} \
QRadioButton { \
padding-left: 25px; \
font-size: 16px; \
color: #333333; \
text-align: center; \
}")
```
在这个例子中,我们设置了一个样式表来定义QRadioButton的外观和行为。我们使用了"text-align: center"来居中文本。请注意,样式表中的"padding-left"值必须大于或等于指示器的宽度,以使文本居中。
阅读全文