Jan-02-2019, 05:55 PM
The combo is not shown because it (self.dd) is not added to the layout. You should subclass QComboBox directly instead of QWidget, unless you really need QWidget methods.
#!/usr/bin/python3 import sys from PyQt5 import QtCore, QtGui, QtWidgets class Main(QtWidgets.QMainWindow): def __init__(self, parent): super().__init__() self.ui = QtWidgets.QWidget(self) self.setCentralWidget(self.ui) self.ui.combo = PartRoleComboBox() self.ui.layout = QtWidgets.QVBoxLayout() self.ui.layout.addWidget(self.ui.combo) self.ui.setLayout(self.ui.layout) self.show() 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) class PartRoleComboBox(QtWidgets.QComboBox): def __init__(self): QtWidgets.QWidget.__init__(self) #self.parent_form = form self.available_options = ['Hardware', 'Base', 'Case', 'Drawer'] self.addItems(self.available_options) self.currentIndexChanged.connect(self.part_role_selection_changed) ##self.setObjectName(object_name) # dd.setToolTip("Choose a part role to configure", None) self.sizeHint() def part_role_selection_changed(self): print("dropdown selection changed") print(self.currentText()) #self.parent_form.add_part_role_shadows_table(self.currentText()) if __name__== '__main__': app = QtWidgets.QApplication([]) gui = Main(app) sys.exit(app.exec_())