[PyQt] embedding iconic pushButton in TableView and/or TreeView
James Polk
jpolk5001 at yahoo.com
Thu Nov 25 02:33:28 GMT 2010
Woooohooooo....I got a custom delegate installed....at least partially, lol...
Using the basic QItemDelegate
I've first tried a comboBox, which seems a little more straightforward,..
When using QTableView,...the "index.column()" calls want text matching
the column headings,...but in QTreeView, the same call wants an integer index#...so my code looks like...
def createEditor(self, parent, option, index):
if index.column() == 0: # Thumbnail
button = QPushButton(parent)
return button
if index.column() == 4: # Format
comboBox = QComboBox(parent)
comboBox.addItem("ma")
comboBox.addItem("mb")
comboBox.addItem("obj")
comboBox.setEditable(True)
return comboBox
return QItemDelegate.createEditor(self, parent, option, index)
I was all in celebration mode,...until I began to add the initial
pushbutton/icon in the first column.....Right now, I'm just using
QPushButton and will add the image/pixmap later...
Well..the danged curious thing is....that when I run the code,
and double-click on the cells of the first column, the custom
delegate dutifully returns a nice PushButton....but my conundrum
is that I still can't figure out how to add the PushButton to the
QTreeView on startup!...<sigh>....
You may recall the data layout I'm going for is something like...
1 [icon1] data data data etc
2 [icon2] data data data etc
3 etc
4 etc
...and later,...when a user binks on the icon, it will need to execute
a command...
So,...some progress, but still more jungle ahead,lol...<sigh>
Maybe I'll go reread your stardelegate code again ;-)
Cheers,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101124/2dea174b/attachment.html>
More information about the PyQt
mailing list