Results 1 to 4 of 4

Thread: QTableview, checkboxes and SQlite

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QTableview, checkboxes and SQlite

    You have to create your own data model inheriting from QSqlTableModel.
    Reimplement flags() method and use Qt::ItemIsUserCheckable for the column with the checkbox.
    Reimplement data() and setData() to manage the role Qt::CheckStateRole properly for the column with the checkbox.

  2. #2

    Default Re: QTableview, checkboxes and SQlite

    Ok, I'm trying to do that, I have the delegate but I don't know how to link with the database. Can you give me an example?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableview, checkboxes and SQlite

    nix suggested to create a subclass of the model you are currently using, so that you can either make one of the existing columns checkable or add a column.
    Another option is to use a proxy model.

    Delegate has nothing to do with that.

    Cheers,
    _

Similar Threads

  1. Bigger checkboxes in QTableView?
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2012, 12:13
  2. No checkboxes are displayed in a QTableView
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2010, 17:28
  3. Unsolicited checkboxes in QTableView
    By MattPhillips in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2009, 21:44
  4. QTableView and checkboxes
    By ibergmark in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2008, 15:20
  5. Replies: 2
    Last Post: 23rd February 2008, 01:58

Tags for this Thread

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.