[PyQt] Question TreeView, delegates, and functions

James Polk jpolk5001 at yahoo.com
Wed Jan 12 03:19:55 GMT 2011


Okay,..I gotta' good one for ya'll...lol

I have a TreeView displaying data,..it's supported by a 
QStyleItemDelegate that's controlling the editing/display of various cells
in the TreeView. There is a plainTextEdit window also in the main
window. When a user makes a selection in the TreeView, 
the "selectionChanged" function retrieves some data and displays it 
in the plainTextEdit.  So far so good, right?

Okay, so when I double-click on a cell, the delegate properly
shows me a comboBox,....I pick an item and hit return, and
while the cell properly updates,...the delegate doesn't trigger
"selectionChanged" in the TreeView, and in turn, doesn't trigger
the text in the plainTextEdit box to be updated either.

In the delegate, in "setModelData", I can intercept the proper
row,column,cell,etc...but I can't find the right syntax to call the
"selectionChanged" function because I can't determine the
parent....

in main.py, 

self.selectionModel.selectionChanged.connect(self.treeViewSelectionChanged)

and the function:

    def treeViewSelectionChanged(self):
                  statement
                  statement
                  etc

all normal enough,...but in the "main_delegate.py"..."self" does not
mean the MainWindow in "main.py"...
The "createEditor" function in the delegate file does have a "parent"
argument, but the "setModelData" function does not.  I'm assuming
that if it did,..I could call

 parent.treeViewSelectionChanged()

As an alternative, I thought I could just update the plainTextEdit
box "manually" from setModelData in the delegate, but again,
same problem....

Could I make the control "self.plainTextEdit" global ?
so that I could call it from the delegate...

Any help or advice would be most greatly appreciated,
Cheers,
-James




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110111/b92da667/attachment.html>


More information about the PyQt mailing list