【发布时间】:2020-11-30 18:22:36
【问题描述】:
知道,我尝试使用 pyqt 制作 GUI。 我想在程序开始时隐藏一些小部件,并在我选择 Combobox 时显示。 可以在程序开始时隐藏一些小部件。但是,当我选择 Combobox 时,不可能显示特定的小部件。你能给我一些解决这个问题的建议吗?
class MyForm(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.oneLayerWidget.setVisible(False)
self.ui.twoLayerWidget.setVisible(False)
self.ui.layTypeComboBox.clear()
self.ui.layTypeComboBox.addItems(["Original Layer", "Boolean Layer"])
self.ui.layTypeComboBox.currentIndexChanged.connect(self.layTypeSelEvent)
def layTypeSelEvent(self):
layType = str(self.ui.layTypeComboBox.currentText())
if layType == "Original Layer":
self.ui.twoLayerWidget.setVisible(False)
self.ui.oneLayerWidget.setVisible(True)
elif layType == "Boolean Layer":
self.ui.oneLayerWidget.setVisible(False)
self.ui.twoLayerWidget.setVisible(True)
【问题讨论】:
标签: python pyqt pyqt4 qt-designer