QSqlRelationalTableModel: How To Reimplement data & setData



  • Hi All,

       Could you please help clarifying what to put when reimplementing data & setData for QSqlRelationalTableModel.  The following doesn't write anything to the dB. 
    

    @class Model(QSqlRelationalTableModel):
    def init(self, parent=None):
    QSqlRelationalTableModel.init(self, parent)

        self.setQuery(QSqlQuery("SELECT * from titles WHERE user=1"))
        self.setEditStrategy(QSqlTableModel.OnFieldChange)      
        self.select()
     
    def setData(self, index, value, role=Qt.EditRole):
        if role == Qt.EditRole:
            self.index = value
            return True
    

    class Table(QWidget):
    def init(self, parent=None):
    QTableView.init(self, parent)

        self.t = QTableView()
        self.model = Model()
        self.t.setModel(self.model)
        self.t.show()
    

    new = Table(); new
    @

    Much appreciated


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.