I figured it out, when the role was the BackgroundRole, I was switching on the background color value, not on the actual value (Qt:isplayRole). After the code gets into the Qt::BackgroundRole, I now do a int stateCode = QSqlQueryModel::data(index, Qt:isplayRole).toInt(); and switch off that, it works GREAT!