AttributeError: 'MainWindow' object has no attribute 'Region_comboBox'
-
I don't know what I'm doing wrong here. I have sat behind this the whole time trying to figure out this error. Please any assistance would help.Thanks
class MainWindow(QtWidgets.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.model = QtGui.QStandardItemModel() self.Region_comboBox.setModel(self.model) self.District_comboBox.setModel(self.model) data = { "A": ["a1", "a2"], "B": ["b1", "b2"], "C": ["c1", "c2"], "D": ["D1", "D2"] } # add data for k, v in data.items(): region = QStandardItem() self.model.appendRow(region) for value in v: district = QStandardItem() region.append(district) self.Region_comboBox.currentIndexChanged.connect(self.updateRegionCombo) self.updateRegionCombo(0) def updateRegionCombo(self, index): indx = self.model.index(index, 0, self.Region_comboBox.rootModelIndex()) self.District_comboBox.setRootModelIndex(indx) self.District_comboBox.setCurrentIndex(0)
-
I don't know what I'm doing wrong here. I have sat behind this the whole time trying to figure out this error. Please any assistance would help.Thanks
class MainWindow(QtWidgets.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.model = QtGui.QStandardItemModel() self.Region_comboBox.setModel(self.model) self.District_comboBox.setModel(self.model) data = { "A": ["a1", "a2"], "B": ["b1", "b2"], "C": ["c1", "c2"], "D": ["D1", "D2"] } # add data for k, v in data.items(): region = QStandardItem() self.model.appendRow(region) for value in v: district = QStandardItem() region.append(district) self.Region_comboBox.currentIndexChanged.connect(self.updateRegionCombo) self.updateRegionCombo(0) def updateRegionCombo(self, index): indx = self.model.index(index, 0, self.Region_comboBox.rootModelIndex()) self.District_comboBox.setRootModelIndex(indx) self.District_comboBox.setCurrentIndex(0)
-
I don't know what I'm doing wrong here. I have sat behind this the whole time trying to figure out this error. Please any assistance would help.Thanks
class MainWindow(QtWidgets.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.model = QtGui.QStandardItemModel() self.Region_comboBox.setModel(self.model) self.District_comboBox.setModel(self.model) data = { "A": ["a1", "a2"], "B": ["b1", "b2"], "C": ["c1", "c2"], "D": ["D1", "D2"] } # add data for k, v in data.items(): region = QStandardItem() self.model.appendRow(region) for value in v: district = QStandardItem() region.append(district) self.Region_comboBox.currentIndexChanged.connect(self.updateRegionCombo) self.updateRegionCombo(0) def updateRegionCombo(self, index): indx = self.model.index(index, 0, self.Region_comboBox.rootModelIndex()) self.District_comboBox.setRootModelIndex(indx) self.District_comboBox.setCurrentIndex(0)
-
@LT-K101 Change
self.Region_comboBox
toself.ui.Region_comboBox
, andself.District_comboBox
toself.ui.District_comboBox
.@eyllanesc Thanks a lot it worked perfectly