[PyQt] embedding iconic pushButton in TableView and/or TreeView

Hans-Peter Jansen hpj at urpla.net
Wed Nov 24 19:39:28 GMT 2010


On Wednesday 24 November 2010, 19:10:05 James Polk wrote:
> >I've transcoded the stardelegate example a few weeks ago, which uses
> > a custom widget in a QTableView, but due to the model/view/delegate
> > pattern, that should be easy to map onto your problem.
> >
> >Pete
>
> Thanks for your reply, Pete...

You're welcome, James.

> I reread chap's 14,15, and 16 from Mark Summerfield's book overnight,
> and it made things a bit clearer...I need to create a custom
> delegate...

Yes, the model/view/delegate pattern takes a little "getting used to" 
and some practice in order to master it. 

Marks contribution to this project is just outstanding. I'm reading his 
newest book "Advanced Qt Progamming" ATM. While it is C++ centered, 
it's a pleasure to read, and as always quite an enrichment for my PyQt 
centered programming brain. And as a nice side effect, it improves the 
built in "C++ to Python converter" subsection in there. ;) 

> I think I also need to do a sanity check about whether to use
> QTableView or QTreeView.  Since the heart of my application is
> to be able to sort various categories based on various criteria,
> I chose to use the example program "BasicSortFilter" as a starting
> point,...the "SortFilter" process gives me just what I need, and it
> used QTreeView with decoration(false) to make it appear tabular.
>
> It also looks like custom delegates are easier to implement in
> TableView, rather than TreeView, but that difference may be
> more superficial than real.
>
> I'll do a search for your stardelegate code and see what I can learn
> from it.  Many Thanks for offering that ;-)

You can find it in the examples of the latest PyQt version already. If 
you want to try it, you need that version installed, since it uses 
__lshift__ for setting up QPolygonF's. But I also posted replacement 
code to get it going in former releases by the price of a little 
editing.. 

Cheers,
Pete


More information about the PyQt mailing list