Subclassing QSqlTableModel to overwrite setQuery
Hi folks
I wonder why setQuery in QSqlTableModel is protected?
I thought I need this feature, so I subclassed QSqlTableModel.
Now, what you guys recommend: Subclass or no to subclass?
Cause Qt had his reasons to made setQuery protected I think...
Maybe I'm not as clever as I thought? :o
Re: Subclassing QSqlTableModel to overwrite setQuery
It's protected, because QSqlTableModel is for selecting all columns from a single table, so you only have to supply the table name. You can customize parts of the query by calling or reimplementing certain methods, but if you want to have a full control over the query, use QSqlQueryModel.
Re: Subclassing QSqlTableModel to overwrite setQuery
selecting all columns of a single table doesn't usually meet our needs. IMHO QSqlTableModel is too restricted to a single case of use.
But thanks jacek for your posting. I think I'm going to use QSqlQueryModel.
Re: Subclassing QSqlTableModel to overwrite setQuery
You can always select rows from a view instead of a table.