Results 1 to 5 of 5

Thread: Prevent edits inQTableView cell

  1. #1
    Join Date
    Jan 2008
    Posts
    39
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Prevent edits inQTableView cell

    Hello

    I am setting the value of a cell in a TableView based on another cell using a custom delegate.

    My question is, how do I prevent edits in the first cell if it is set to a certain value. I suspect that I need to reimplement the flag method in my custom model, however I have tried various combinations of ItemIsEditable and ItemIsSelectable with the result that clicking on the cell selects the entire row. I just want the uneditable cell to be selected when clicking on it.

    What am I doing wrong??

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Prevent edits inQTableView cell

    What are you doing wrong?
    Hmm, might be anything

    Using flags() should work.
    Show us some (compilable) code and we should be able to help you.

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

    Banjo (9th July 2009)

  4. #3
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Prevent edits inQTableView cell

    You say the whole row get's selected? This is probably not an item flag issue, but rather a problem with the selection mode settings
    (see QAbstractItemView::setSelectionMode)
    Andreas

  5. The following user says thank you to ghorwin for this useful post:

    Banjo (9th July 2009)

  6. #4
    Join Date
    Jan 2008
    Posts
    39
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Prevent edits inQTableView cell

    Thanks for your quick replies.

    What I have found is that I used the Designer to create the UI and set the SelectionBehaviour of the TableView to QAbstractItemView.SelectItems. However, and this is a Python application, when the .ui file is created, this setting is not translated. When I set this in code, everything works perfectly.

  7. #5
    Join Date
    Jun 2009
    Location
    Bato, Leyte, Philippines
    Posts
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Prevent edits inQTableView cell

    Try this. It works on my project.

    empview->setEditTriggers(QAbstractItemView::NoEditTriggers );

Similar Threads

  1. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  2. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57

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.