Results 1 to 2 of 2

Thread: QTableView enable

  1. #1
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableView enable

    Hi,
    I have a Qtableview in my project and i want that the first column is editable but not the second column.

    How i can setEnebled(false) only for the second column?

    Thanks, Bye

  2. #2
    Join Date
    May 2010
    Location
    Russia
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTableView enable

    Hi, i think you can solve this problem in two ways:

    1. if you use own model class you can reipliment flags method like this:
    Qt Code:
    1. Qt::ItemFlags Model::flags(const QModelIndex &index) const
    2. {
    3. if (!index.isValid())
    4. return 0;
    5.  
    6. if (index.column() == 1)
    7. return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
    8.  
    9. return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
    10. }
    To copy to clipboard, switch view to plain text mode 

    2. Or just use delegation mechanism - subclass QStyledItemDelegate, reimplement necessary methods in particular method createEditor (should return 0 for second column index). Set up delegation class to you QTableView class using setItemDelegateForColumn method

Similar Threads

  1. How to Enable Touchscreen
    By Rajeshsan in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th September 2009, 07:51
  2. enable all Tooltips
    By clive in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2008, 11:08
  3. enable layout
    By mickey in forum Newbie
    Replies: 6
    Last Post: 12th July 2006, 23:00
  4. How to enable QWS_IM in qte-3.3.5 ?
    By kevin lin in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 29th June 2006, 06:40
  5. QTableView - Enable Clicking for some columns only
    By Gabriel in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2006, 22:42

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