[PyQt] Cannot get data to be fetched by QTableView through QAbstractTableModel

Bjorn Egil Ludvigsen bludvigsen at gmail.com
Tue Apr 27 14:29:38 BST 2010


FYI, this problem was fixed by using "self.reset()" directly after loading
data.

Bjorn

On Fri, Apr 23, 2010 at 9:14 AM, Bjorn Egil Ludvigsen
<bludvigsen at gmail.com>wrote:

> Yes thanks, I deliberately left those out, but they are working fine (as I
> know by having debug output to my log window) and looks like below. I also
> have headerData(). My header is showing up just fine by the way. The
> vertical header is not shown, even if I set it to be shown, which is strange
> because both rows and columns are returned properly:
>
>     def rowCount(self, index=QModelIndex()):
>         return len(self.uncertainties)
>
>     def columnCount(self, index=QModelIndex()):
>         return len(Uncertainty.uncertaintyAttrList)
>
>     def headerData(self, col, orientation, role):
>         if orientation == Qt.Horizontal and role == Qt.DisplayRole:
>             return Uncertainty.uncertaintyAttrList[col]
>         return None
>
>
>
>
> On Fri, Apr 23, 2010 at 9:01 AM, Andreas Pakulat <apaku at gmx.de> wrote:
>
>> On 23.04.10 08:36:22, Bjorn Egil Ludvigsen wrote:
>> > Hi,
>> >
>> > I cannot get any data to be shown in my QTableView and wonder now if
>> > something could be wrong with returning the QVariants(), as someone on
>> > Daniweb said this is not necessary anymore after PyQt 4.6. Also I read
>> the
>> > PyQt documentation about QVariant, but have not gotten any further.
>> >
>> > Without giving you the whole nine yards, can anyone spot any beginners
>> error
>> > below? The data itself is loaded into a list (self.uncertainties) of
>> > Uncertainty() objects. An Uncertainty() has 22 attributes that I want to
>> > show in a table.
>>
>> Unless you deliberitly left these out the below model misses
>> implementations for at least rowCount and columnCount.
>>
>> Andreas
>>
>> --
>> It was all so different before everything changed.
>> _______________________________________________
>> 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/20100427/24f71fd4/attachment.html>


More information about the PyQt mailing list