mirror of
https://github.com/muziing/PySide6-Code-Tutorial.git
synced 2025-02-07 00:28:22 +08:00
Add 03-02-02-02
This commit is contained in:
parent
bf34c9ada9
commit
8bcc0d6806
@ -0,0 +1,35 @@
|
||||
import sys
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
"""
|
||||
QPushButton 扁平化
|
||||
设置扁平化后,除非按钮被按下,大部分样式不会绘制按钮背景,实现视觉上的扁平化
|
||||
|
||||
.setFlat(bool) 是否设置为扁平化,默认为否
|
||||
.isFlat() -> bool 是否为扁平化
|
||||
"""
|
||||
|
||||
|
||||
class MyWidget(QtWidgets.QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.setWindowTitle("QPushButton-扁平化")
|
||||
self.resize(800, 600)
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self) -> None:
|
||||
"""设置界面"""
|
||||
# 在此处编写设置UI的代码
|
||||
button = QtWidgets.QPushButton("扁平化的按钮", self)
|
||||
button.setFlat(True) # 启用扁平化
|
||||
button.move(350, 200)
|
||||
|
||||
print(button.isFlat())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([])
|
||||
window = MyWidget()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
Loading…
x
Reference in New Issue
Block a user