Results 1 to 4 of 4

Thread: Make a column readonly/not editable in QTableView?

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Make a column readonly/not editable in QTableView?

    Hi,

    How can I make the cells of a column in a QTableView not editable? I am using QAbstractTableModel

    Thanks,
    Carlos.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Make a column readonly/not editable in QTableView?

    You can set a Item Delegate for Column with QAbstractItemView::setItemDelegateForColumn() and implements a read-only delegate.

    Alternative you can your model and in QAbstractItemModel::flags you can remove the Qt::ItemIsEditable for specified column
    A camel can go 14 days without drink,
    I can't!!!

  3. The following user says thank you to mcosta for this useful post:

    gkarthick5 (1st August 2011)

  4. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Make a column readonly/not editable in QTableView?

    Cool!. Thanks.

  5. #4
    Join Date
    Jun 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Make a column readonly/not editable in QTableView?

    very good. i do it

Similar Threads

  1. Replies: 3
    Last Post: 9th May 2011, 17:23
  2. Make first column freezed in QTableView
    By gutiory in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2010, 06:53
  3. Make a column read-only in a QSqlTableModel/QTableView
    By graciano in forum Qt Programming
    Replies: 0
    Last Post: 15th November 2009, 18:18
  4. Replies: 4
    Last Post: 6th February 2008, 14:15
  5. How to set a column readonly in qtablewidgetitem
    By ashukla in forum Qt Programming
    Replies: 6
    Last Post: 8th November 2007, 13:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.