6.4 QGridLayout
728x90

1. QGridLayout: 표(그리드) 레이아웃
: 행/열로 위젯을 배치하는 2차원 레이아웃 공식문서
더보기



import sys
from PySide6.QtWidgets import (
QApplication, QWidget, QPushButton, QGridLayout
)
class GridExample(QWidget):
def __init__(self):
super().__init__()
b1 = QPushButton("One")
b2 = QPushButton("Two")
b3 = QPushButton("Three")
b4 = QPushButton("Four")
b5 = QPushButton("Five")
layout = QGridLayout(self)
layout.addWidget(b1, 0, 0) # (row=0, col=0)
layout.addWidget(b2, 0, 1) # (0, 1)
layout.addWidget(b3, 1, 0, 1, 2) # (1,0)에서 1행 2열 span
layout.addWidget(b4, 2, 0)
layout.addWidget(b5, 2, 1)
if __name__ == "__main__":
app = QApplication(sys.argv)
w = GridExample()
w.show()
sys.exit(app.exec())
사용된 좌표 의미
- (0, 0) = 0행 0열
- (1, 0) = 1행 0열

2. Qt Designer 에서 QGridLayout 사용하기 (1)
3. Qt Designer 에서 QGridLayout 사용하기 (2)







