【发布时间】:2016-07-11 22:23:24
【问题描述】:
我在 qtdesigner 中创建了一个如下所示的 ui:
并且我想在标题为“方程式”的组框和包含标题为“下标”和“连接元素”的两个组框的布局之间插入另一个包含几个小部件的布局。
我不确定如何插入此附加布局的原因是,当我查看 qtdesigner 中的对象检查器时,我看到了:
它不会告诉我包含对话框窗口中所有其他小部件和布局的垂直布局的名称。
我正在加载用户界面如下:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
class EquationEditor(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
uic.loadUi('equation_editor.ui', self)
# Insert a layout containing a couple of widgets on index change of
# the combobox
self.typeBox.currentIndexChanged.connect(self.enableInitialValueEntry)
def enableInitialValueEntry(self):
vartype = self.typeBox.currentText()
if vartype == "Stock":
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(QLabel("Initial Value"))
hbox.addWidget(QLineEdit())
#How can I insert the layout `hbox`?
【问题讨论】:
标签: python qt pyqt qdialog qlayout