[PyQt] Always show a QLineEdit as QItemDelegate

Linos info at linos.es
Fri Apr 27 08:22:14 BST 2012


El 27/04/12 00:12, Jake Richards escribió:
> Hello:
>   I've got a QTreeView that uses a QLineEdit as a QItemDelegate for one of it's
> columns.  The problem is that I want to display the QLineEdit all the time, not
> just when the user double clicks and starts editing.  Am I using the wrong
> approach to accomplish this?  I was using a QTreeWidget with setItemWidget but
> the docs said that I should only do that if I'm using static data, so I'm
> attempting to use the delegates.  Thank you for any help!
> 

Hello,
	if you want to do this from a delegate, and you should if your view has many
items because a complete widget it is much heavier, you should paint the widget,
much like Qt do, in the paint method of the delegate, using
QApplication.style().drawControl(), in this thread you have an example
http://www.qtcentre.org/threads/18959-QWidget-in-tableview

Regards,
Miguel Angel.


More information about the PyQt mailing list