PDA

View Full Version : Prevent edits inQTableView cell



Banjo
8th July 2009, 07:18
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??

caduel
8th July 2009, 10:54
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.

ghorwin
8th July 2009, 16:35
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)

Banjo
9th July 2009, 00:28
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.

genessr
9th July 2009, 13:27
Try this. It works on my project.

empview->setEditTriggers(QAbstractItemView::NoEditTriggers) ;