@_compiler
Model *derived = static_cast<QSqlQueryModel*>(model);This isn't a valid cast because you can't implicitly cast to a derived type (see @mrjj's comment).
Model *derived = static_cast<Model *>(model);Is valid but unsafe, as @SGaist pointed out.
Ultimately, what is not working?