分割线
Horizontal Line
Vertical Line
spacer
Horizontal Spacer
Vertical Spacer
QtDesigner中示例
代码示例
from PyQt5.QtWidgets import *
import sys
class Window(QWidget):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
button = [0, 0, 0]
for i in range(3):
button[i] = QPushButton(str(i), self)
horizontal_Layout = QHBoxLayout()
horizontal_Layout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
h_line = QFrame()
h_line.setFrameShape(QFrame.VLine)
h_line.setFrameShadow(QFrame.Sunken)
h_line.setObjectName("line")
horizontal_Layout.addWidget(button[0])
horizontal_Layout.addItem(spacerItem)
horizontal_Layout.addWidget(button[1])
horizontal_Layout.addWidget(h_line)
horizontal_Layout.addWidget(button[2])
self.setLayout(horizontal_Layout)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
|