PyQt布局管理器有六种:
- move()方法布局
- 垂直布局管理器QVBoxLayout()
- 水平布局管理器QHBoxLayout()
- 表单布局管理器QFormLayout()
- 网格布局管理器QGridLayout()
- 布局嵌套
move()方法
根据窗口坐标布局,类似Tk的place。
import sys
from PyQt6.QtWidgets import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.resize(200,200)
label1 = QLabel('username:',self)
entry1 = QLineEdit(self)
# label2 = QLabel('password', self)
# entry2 = QLineEdit(self)
# 布局
label1.move(40,40)
entry1.move(80,40)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec())
垂直布局管理器QVBoxLayout()
垂直:Vertical Horizontal: 水平
Y 与 V 有点类似,V就是Y 垂直布局.

import sys
from PyQt6.QtWidgets import *
class Window(QWidget):
def __init__(self):
super().__init__()
label1 = QLabel("username:", self)
entry1 = QLineEdit(self)
label2 = QLabel("password:", self)
entry2 = QLineEdit(self)

最低0.47元/天 解锁文章
3165

被折叠的 条评论
为什么被折叠?



