You're changing the model here which is... well... at least controversial when it comes to the MVC paradigm.
BTW. The model is to be editable so you should subclass QSqlTableModel and also reimplement setData(). Now imagine someone wants to have another view (or access the database through the model) without the checkboxes... Or the column might allow NULLs
Of course I don't say that you can't do it this way, I only say you should do it with a delegate, as you'll be modifying only the user interaction this way. I wrote about it earlier in the thread.
Just for completeness - a third way would be to use a proxy model that would translate between the bool and the checkstate role. That would be my second best suggestion (as it doesn't change the source model).






Reply With Quote
Bookmarks