Recently switched to Pyqt6 databases and can't figure out the value of this enum type:
model.setEditStrategy(QtSql.QSqlTableModel.OnFieldChange)
I've tried:
- Passing in the numerical value of the enum type ie 0. The interpreter complains saying that it can't accept int types.
Has anyone figured what the new value should be? Is there a way I or anyone else can find out for themselves?
from PyQt6.QtWidgets import QMessageBox, QApplication, QTableView, QVBoxLayout, QPushButton, QWidget
from PyQt6.QtSql import QSqlDatabase, QSqlTableModel
from PyQt6 import QtCore
from PyQt6 import QtSql
def initializeModel(model):
model.setTable('authors1')
model.setEditStrategy(QtSql.QSqlTableModel.OnFieldChange)
model.select()
model.setHeaderData(1, QtCore.Qt.Orientations.Horizontal, 'Author name(s)')
def createView(model):
view = QTableView()
view.setModel(model)
view.resize(230, 254)
view.hideColumn(0)
view.setColumnWidth(1, 200)
return view
def addRecord():
sqm.insertRow(sqm.rowCount())
def delRecord() :
sqm.removeRow(view1.currentIndex().row())
sqm.select()