Important: Please read the Qt Code of Conduct -

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"))
    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()

    new = Table(); new

    Much appreciated

Log in to reply