[PyKDE] Abstract Table Model + TableView

David Boddie david at boddie.org.uk
Tue Jan 30 23:48:38 GMT 2007


On Tue Jan 30 23:45:23 MET 2007, Kelly Burkhart wrote:

> I'm experimenting with QAbstractTableModel + QTableView and having a
> difficult time getting what I expect.  I'm hoping with the attached
> code to create a grid with a header and each cell showing some text.
> Instead I'm getting a grid with no header (tableview.header().show()
> has no effect) and cells that look like check box widgets.
> 
> Can anyone spot some obvious problems with my code?

Yes, you're returning QVariants containing empty strings when you mean
to return invalid QVariants. Change all occurrences of QVariant('') to
QVariant() and it should work as you expect.

> With QTableView does one have to manually create header and enable
> column resizing?  Or is there some hidden switch that I'm not touching
> that enables this functionality?

It should just work. There are some subtleties with expanding columns
and rows to optimize the space allocated to items - just ask again if
you encounter problems along those lines.

David




More information about the PyQt mailing list