[PyQt] item delegates

Mads Ipsen mpi at comxnet.dk
Thu Feb 5 11:46:44 GMT 2009


--------- Original Besked --------
Fra: Baba-k <babakage at gmail.com>
Til: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Emne: Re: [PyQt] item delegates
Dato: 05/02/09 11:09

> 
> Hi Mads,
> 
> I dunno if this is the best way of doing it but could you test to see
which
> row/column the item is inside the delegate and if its not in the correct
one
> then call the parent class method for creating the editor widget otherwise
> use yours, for example..
> 
> class myDelegate(QtGui.QItemDelegate):
>   ....
>   def createWidget(self, index ...):
>      if index.column() != someColumn and index.row() != someRow:
>          return QtGui.QItemDelegate(self, index, ... )
>    
>     return myWidget
> 
> if that makes sense, could be over kill though. Alternatively if you are
> using a custom model you might be able to set some flags on the cell you
> want and not the others.
> 
> hope that helps
> babak
> 
> 
> Mads Ipsen-3 wrote:
> &gt; 
> &gt; Hi,
> &gt; 
> &gt; Suppose I have a TableView. Then I can set itemdelegates for a
column, a
> &gt; row
> &gt; or the entire view using the respective methods
> &gt; 
> &gt; void setItemDelegateForColumn ( int column, QAbstractItemDelegate *
> &gt; delegate
> &gt; )
> &gt; void setItemDelegateForRow ( int row, QAbstractItemDelegate *
delegate )
> &gt; void setItemDelegate ( QAbstractItemDelegate * delegate )
> &gt; 
> &gt; All this is fine. But how do I specify a delegate for a single cell
in the
> &gt; table?
> &gt; 
> &gt; Mads
> &gt; _______________________________________________
> &gt; PyQt mailing list    PyQt at riverbankcomputing.com
> &gt; http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> &gt; 
> &gt; 
> 
> -- 
> View this message in context:
http://www.nabble.com/item-delegates-tp21846648p21848453.html
> Sent from the PyQt mailing list archive at Nabble.com.
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 

That actually how I do it. But, as you point out, its somewhat overkill. 

Mads


More information about the PyQt mailing list