qpushbutton,设置图标在上,文字在下
时间: 2023-05-17 14:02:34 浏览: 153
可以使用QVBoxLayout和QHBoxLayout来实现这个布局。首先,将QPushButton添加到布局中,然后使用setStyleSheet()方法设置按钮的样式表,以将图标放置在按钮的顶部,文字放置在底部。以下是示例代码:
```python
button = QPushButton("Button Text")
layout = QVBoxLayout()
layout.addWidget(button)
button.setStyleSheet("QPushButton {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"image: url(path/to/icon.png);"
"}"
"QPushButton::indicator {"
"width: 0px;"
"height: 0px;"
"}"
"QPushButton::menu-indicator {"
"width: 0px;"
"height: 0px;"
"}"
"QPushButton::default {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::focus {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::hover {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::pressed {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::checked {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::unchecked {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::disabled {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::flat {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::default {"
"border: none;"
"padding: 0px;"
"background-color: transparent;"
"}"
"QPushButton::indicator:checked {"
"image: url(path/to/checked_icon.png);"
"}"
"QPushButton::indicator:unchecked {"
"image: url(path/to/unchecked_icon.png);"
"}"
"QPushButton::menu-indicator {"
"image: none;"
"}"
"QPushButton::menu-indicator:pressed {"
"image: none;"
"}"
"QPushButton::menu-indicator:unchecked {"
"image: none;"
"}"
"QPushButton::menu-indicator:checked {"
"image: none;"
"}"
)
layout.setAlignment(Qt.AlignCenter)
```
关于lua closure factory的完整代码和中文加密的问题,我需要更多的信息才能回答。
阅读全文