[PyQt] TableModel

Marc Nations mnations.lists at gmail.com
Tue Feb 10 19:40:23 GMT 2009


You don't need to worry about the abstract model just to get data into a
table. I believe it's simplest form is just creating a table item and
inserting it in the table.
For a string (using unicode):

> item = QtGui.QTableWidgetItem( unicode(data))
>
table.setItem(rowCount,  colCount,  item )
>


For data:

> item= QtGui.QTableWidgetItem( 0 )

item.setData( 0,  QtCore.QVariant( data )

table.setItem(rowCount,  colCount,  item )



I'm new to this myself, but this is the way that I have it working.


On Tue, Feb 10, 2009 at 1:07 PM, Brian Makin <merimus at gmail.com> wrote:

> I need to create a table with string and number fields.  I'm having a bit
> of problem getting this to work.  What is the correct way to do this?
>
> It doesn't look like TableModel handles numbers so do I need to subclass
> abstract table model et al?
>
> Are there any handy examples of this (including sorting of the columns)?
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090210/0a0bfcba/attachment.html


More information about the PyQt mailing list