QSqlQueryModel does not accept data for BackgroundRole. Either subclass it and teach the subclass to return (and accept) the proper data or apply a custom proxy that would do it (the one you have seems to be able to do it).