Jan-02-2019, 03:49 PM
I need to dynamically add combos to a parent form. Selecting a value in the combo should call a method in the parent form to dynamically update the screen.
I've created a custom ComboBox class that inherits from QWidget:
Any ideas?
I've created a custom ComboBox class that inherits from QWidget:
from PyQt4 import QtCore, QtGui
class PartRoleComboBox(QtGui.QWidget):
def __init__(self, form, object_name):
QtGui.QWidget.__init__(self)
self.parent_form = form
self.dd = QtGui.QComboBox()
self.available_options = ['Hardware', 'Base', 'Case', 'Drawer']
self.dd.addItems(self.available_options)
self.dd.currentIndexChanged.connect(self.part_role_selection_changed)
self.dd.setObjectName(object_name)
# dd.setToolTip("Choose a part role to configure", None)
self.dd.sizeHint()
def part_role_selection_changed(self):
print("dropdown selection changed")
self.parent_form.add_part_role_shadows_table(self.currentText())And in the parent form, I have a method to add the dropdown: def add_part_role_dropdown(self):
# Add a dropdown control containing list of part roles
obj_name = "ddnSection" + str(self.section)
dd = prCombo(self.form, obj_name)
self.gridLayout.addWidget(dd, self.section+4, 1, 1, 1, QtCore.Qt.AlignHCenter)I'm not getting an error message, or any feedback. It steps through the code cleanly, but the combo is never shown to the user.Any ideas?
