Implement setData for QSqltable to be editable

This commit is contained in:
2024-08-06 09:55:48 +02:00
parent 6e55415282
commit 100cb75c09
2 changed files with 21 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
#modifie the QSqlQueryModel to be editable and sets them to the database
from PySide6.QtSql import QSqlQueryModel, QSqlQuery
from PySide6.QtCore import Qt
#credits to :
#https://stackoverflow.com/questions/49752388/editable-qtableview-of-complex-sql-query
@@ -32,6 +33,9 @@ class SqlQueryModel_editable(QSqlQueryModel):
result = q.exec_()
if result:
self.query().exec_()
# print("filter_value:",filter_value)
print("setdata query: ",query.format(value, filter_value))
print("index.row:",index.row(), "filter_col:",filter_col)
else:
print(self.query().lastError().text())
return result