Results 1 to 3 of 3

Thread: How to disable some columns from editing on a QTableWidget?

  1. #1
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to disable some columns from editing on a QTableWidget?

    Hi,

    I would like one column in my QTableWidget to be editable. With other columns read only.

    I have done similar code on a different compiler by changing from single selection to row selection when the read only columns are selected.

    Any ideas on how to achieve this?

    Thanks
    Brendan

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to disable some columns from editing on a QTableWidget?

    Use QTableWidgetItem::column() to determine whether to edit or not. Better still, while new'in QTableWidgetItem, set its flags appropriately.
    QTableWidgetItem *item = new QTableWidgetItem();
    item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled );

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

    grantbj74 (21st September 2011)

  4. #3
    Join Date
    Aug 2009
    Location
    Brisbane, Australia
    Posts
    75
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to disable some columns from editing on a QTableWidget?

    Yes that does exactly what I want. Thanks

Similar Threads

  1. QSpinBox: how to disable line editing?
    By vonCZ in forum Newbie
    Replies: 10
    Last Post: 23rd April 2009, 15:37
  2. QTableWidget: Disable 'snapping' to rows and columns?
    By PolyVox in forum Qt Programming
    Replies: 2
    Last Post: 8th October 2008, 20:04
  3. Resizing QTableWidget Columns
    By mbrusati in forum Qt Programming
    Replies: 4
    Last Post: 29th September 2008, 22:26
  4. QTableWidget - images in columns
    By bruccutler in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 18:28
  5. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46

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.