[PyQt] setEditTriggers

Scott Frankel frankel at circlesfx.com
Sun Jul 20 05:45:28 BST 2008

Problem found:  I needed to implement flags() and setData() in my  
model.  I knew it was going to be something I overlooked.

Better question(s):

- What's the proper way to implement setData() for a tree model?  I've  
extended QAbstractItemModel with methods that add branches and leaves  
to populate the tree in the first place.  Does setData() call them  
again?  Yes, I'm puzzled ;)

- How can flags() be coaxed to make only one column's fields editable?

I'm on to exploring delegates next, to give my editable tree fields  

Thanks in advance (again)!  Still wrapping my head around MVC tree  

On Jul 19, 2008, at 6:19 PM, Scott Frankel wrote:

> Hello,
> How does one allow the fields of a tree to be editable?
> I've read that items of a tree widget are not editable by default.    
> By setting setEditTriggers(), one can control editability.  That  
> gets set on the view, right?  I've got a pure model that the view  
> gets set to.  Is there something I need to do there as well?
> Here's a portion of my view code:
> 		self.theView = QtGui.QTreeView()
> 		self.theView.setEditTriggers(QtGui.QTreeView.DoubleClicked)
> 		self.theView.setSelectionBehavior(QtGui.QTreeView.SelectItems)
> 		self.theView.setUniformRowHeights(True)
> 		self.theView.setAlternatingRowColors(True)
> Double-clicking on a field just opens/closes that tree branch's  
> nesting.  Setting the edit triggers to AllEditTriggers yields the  
> same results:  no editability.
> Thanks in advance!
> Scott
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Scott Frankel
President/VFX Supervisor
Circle-S Studios
510-339-7477 (o)
510-332-2990 (c)

More information about the PyQt mailing list