PDA

View Full Version : Different data types in a QSqlQueryModel



Lodas
27th February 2008, 16:24
Hello everybody,

this might be a easy question but I couldn't figure it out how to solve the follwing problem:

I have a database with several tables. Each table has columns which hold different kind of datatypes for example one column is boolean and one is varchar(40) another is integer or double.
I use a subclassed QSqlQueryModel to model the database and a QTableView to present the model. The user has the possibility to enter datas into the QTableView and from there the entered values will be written to the database.

However, if I want to change the value of a boolean column I can enter every double value and not just a 1 or a 0. Is it somehow possible to tell the model it should only accept boolean values for a boolean column?

I tried to subclass the data and setdata functions of the model but it didn't work quite well.

Hope someone can help me.

Bye,

Andy

jpn
27th February 2008, 16:31
I tried to subclass the data and setdata functions of the model but it didn't work quite well.
Yes, that's a good approach. Could you show the implementation?