Skip to content

Instantly share code, notes, and snippets.

@44hero
Last active March 21, 2024 02:56
Show Gist options
  • Save 44hero/762069b785a1d6490dcac08f7be9fb15 to your computer and use it in GitHub Desktop.
Save 44hero/762069b785a1d6490dcac08f7be9fb15 to your computer and use it in GitHub Desktop.
# -PySide2- 未だ混乱をきたす、addLayout, setLayout, addWidget について --- * **addLayout** <Layout に Layout を**追加** の意> `xxxLay.addLayout(zzzLay)` --- * **setLayout** <Widget に Layout を**作成しセット** の意> ``` zzzLay = QxxxLayout() xxxWid.setLayout(
# 親layout
# ├ 親layout.addLayout(子layout)
# └ 親layout.addLayout(子layout)
# のパターン
# QHBoxLayoutを2つ用意しています。
# これらを、QVBoxLayout1つでまとめたいと思います。
# 一番理解しやすく視認性のある、簡単な記述をください。
# 但し、
# def createUI(self):
# ...
# に追加してください。
# QHBoxLayoutを2つ作成
hbox_layout1 = QHBoxLayout()
hbox_layout2 = QHBoxLayout()
# hbox_layout1にUI要素を追加
hbox_layout1.addWidget(widget1)
hbox_layout1.addWidget(widget2)
...
# hbox_layout2にUI要素を追加
hbox_layout2.addWidget(widget3)
hbox_layout2.addWidget(widget4)
...
# QVBoxLayoutを作成し、hbox_layout1とhbox_layout2を追加
vbox_layout = QVBoxLayout(self.central_wid)
vbox_layout.addLayout(hbox_layout1)
vbox_layout.addLayout(hbox_layout2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment