QSqlTableModel 继承 QSqlQueyModel,它有一个 public
QSqlQuery QSqlQueryModel::query () const
您可以连接到 QSqlTableModel 发出的四个更改信号
void beforeDelete ( int row )
void beforeInsert ( QSqlRecord & record )
void beforeUpdate ( int row, QSqlRecord & record )
void primeInsert ( int row, QSqlRecord & record )
(问题:我认为 primeInsert 和 BeforeInsert 可以为同一个事件发出,不确定)
子类化并重新实现 submit() 以在调用父提交之前发出包含 QSqlQuery 的信号:
bool YourChildModel::submit ()
{
emit yourSignal(query());
return QSqlTableModel::submit()
}
QsqlQuery有
QString QSqlQuery::lastQuery () const
Returns the text of the current query being used, or an empty string if there is no current query text.
QString QSqlQuery::executedQuery () const
Returns the last query that was successfully executed.
In most cases this function returns the same string as lastQuery(). If a prepared query with placeholders is executed on a DBMS that does not support it, the preparation of this query is emulated. The placeholders in the original query are replaced with their bound values to form a new query. This function returns the modified query. It is mostly useful for debugging purposes.
这将用于解析为 xml。