Results 1 to 2 of 2

Thread: Different data types in a QSqlQueryModel

  1. #1
    Join Date
    Feb 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Different data types in a QSqlQueryModel

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Different data types in a QSqlQueryModel

    Quote Originally Posted by Lodas View Post
    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?
    J-P Nurmi

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 03:59
  2. conversion of binay data to qt types
    By rajeshs in forum Qt Programming
    Replies: 16
    Last Post: 4th January 2008, 12:26
  3. QVariant::toString and custom data types
    By Vladimir in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2007, 15:36
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Use QVariant with custon data types
    By mcosta in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 14:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.