[PyQt] TreeView delegate operations
jpolk5001 at yahoo.com
Wed Jan 19 01:59:50 GMT 2011
Having a real problem figuring this one out, am hoping you guys
can shed some light on this...
In my treeview, I have decoration turned off, so it looks like a
table or spreadsheet,...I have a delegate (that's been working fine)
that handles the display of items in the treeview, right...
Across the columns of the view, there are a several different item
types, an icon, text, date, time, more text,etc...have all been
There is a cell (let's call it cell-4) that is edited by a comboxBox
in the delegate. When the user changes it by selection,
I've added code in the delegate that will also change it's
next door neighbor cell (let's call this cell-5)
(This "next-door-neighbor" was originally a "DateEdit" cell,
that presents a calendarPopup when it's edited,etc.)
The problem is...I double-click on cell-4, and I change
it's contents, it in turn changes cell-5's contents.
However, now when I double-click on cell-5, it resets the
date....losing the original date that was displaying correctly.
Now the code that's run when cell-4 is edited makes sure
to change cell-5 by using the same formating that happens
when the program is first run,,..namely
QtCore.QDate.fromString( dataString , DATE_FORMAT) )
the whole line is actually
model.setData(index, QtCore.QDate.fromString( dataString , DATE_FORMAT) )
My delegate has these functions:
def paint(self, painter, option, index):
def sizeHint(self, option, index):
def createEditor(self, parent, option, index):
def setEditorData(self, editor, index):
def setModelData(self, editor, model, index):
Now I emphasize,...that run the program from startup...
without modifying cell-4,..I can double-click on cell-5 all day,
and it responds correctly. I would have thought that the *format*
of a cell...or the data that's in it,...would stick, until changed...
but that doesn't appear to be the case,...as far as my understanding
of the phenomena goes, lol...
Any help or advice would be greatly appreciated...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt