hello<br><br>i need to know how to update a combobox linked to a datawidgetmapper<br>when the table in relation with the mapper model is modified by en external application.<br><br>code:<br><br> def setupModels(self):<br>
"""<br> Initialize all the application models<br> """<br> # setup masterModel<br> self.mModel = QSqlRelationalTableModel(self)<br> self.mModel.setTable(QString("<div>
fattmaster"))<br>
self.mModel.setSort(MDATA, Qt.AscendingOrder)<br> self.mModel.setRelation(MIDCLI, QSqlRelation("clienti",<br> "id", "ragsoc"))<br> self.mModel.setRelation(MIDTDOC, QSqlRelation("tipofatt",<br>
"id", "tfatt"))<br> self.mModel.select()<br><br clear="all"> def setupMappers(self):<br> '''<br> Initialize all the application mappers<br>
'''<br> self.mapper = QDataWidgetMapper(self)<br> self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)<br> self.mapper.setModel(self.mModel)<br> self.mapper.setItemDelegate(QSqlRelationalDelegate(self))<br>
self.mapper.addMapping(self.dateEdit, MDATA)<br> self.mapper.addMapping(self.fattLineEdit, MDOC)<br><br> relationModel = self.mModel.relationModel(MIDTDOC)<br> relationModel.setSort(1, Qt.AscendingOrder)<br>
relationModel.select()<br> self.tipoFattComboBox.setModel(relationModel)<br> self.tipoFattComboBox.setModelColumn(relationModel.fieldIndex("tfatt"))<br> self.mapper.addMapping(self.tipoFattComboBox, MIDTDOC)<br>
<br> relationModel = self.mModel.relationModel(MIDCLI)<br> relationModel.setSort(CRAGSOC, Qt.AscendingOrder)<br> relationModel.select()<br> self.cliComboBox.setModel(relationModel)<br> self.cliComboBox.setModelColumn(relationModel.fieldIndex("ragsoc"))<br>
self.mapper.addMapping(self.cliComboBox, MIDCLI)<br><br> self.mapper.addMapping(self.tipoPagLineEdit, MPAG)<br> self.mapper.addMapping(self.cauLineEdit, MCAU)<br> self.mapper.addMapping(self.noteLineEdit, MNOTE)<br>
self.mapper.toFirst()<br><br> def editCustomers(self):<br> # call the 'clienti' table editor<br> subprocess.call(['python',os.path.join(os.path.dirname(__file__),<br> "clienti.py")])<br>
# update all controls<br> self.setupModels()<br>
self.setupMappers()<br> self.setupTables()<br>-------------------------<br><br>now, if an external application change (eg add a new record on 'clienti' table) the 'clienti' table,<br>how to update the self.cliComboBox control ?<br>
<br>actually i'm 'rebuilding' all controls as you can see on the editCustomers method, is this the only wahy to update the combobox control ?<br><br>thanks.<br><font color="#888888"><br></font></div><br clear="all">
<br>-- <br>"Io oso fare tutto cio' che puo' essere degno di un uomo, chi osa di piu' non lo e'"<br><a href="http://blog.zamprogno.it" target="_blank">http://blog.zamprogno.it</a><br><a href="http://riparazioni.zamprogno.it" target="_blank">http://riparazioni.zamprogno.it</a><br>
<a href="http://www.archlinux.it" target="_blank">http://www.archlinux.it</a><br><br>