[PyQt] Bugs galore in QAbstractTableModel???

Ian hobson42 at gmail.com
Sat Nov 27 23:02:34 GMT 2010


On 27/11/2010 22:23, Baz Walter wrote:
> On 27/11/10 21:27, Ian wrote:
>> On 27/11/2010 21:07, Andreas Pakulat wrote:
>>> On 27.11.10 20:54:01, Ian wrote:
>>>> I am trying to use QAbstractTableModel and I am having more than
>>>> some difficulty.
>>>>
>>>> If I return the correct number to columnCount I get no headers. If I
>>>> return a number that is too big, I get headers, but the model is
>>>> asked for headers and data for columns that don't exist!
>>>>
>>>> Everywhere I return a String in the data() routine, this is
>>>> displayed with a check box - even if I cast it to QVariant.
>>> There's a C++ class called QModelText which sanity-checks models, I
>>> believe that an older version was converted to python and is 
>>> included in
>>> PyQt4. Run it on your model, fix the problems and see wether that 
>>> helps.
>>>
>> Thanks for your reply Andreas,
>> I can find nothing about QModelText, and QModelTest appears to have a
>> few bug reports and
>> nowhere to download it and no instructions as to how to run it, and is
>> not on my hard disks.
>
> the python version andreas is referring to is "modeltest.py". it can 
> be found in the pyqt source in the contrib/pymodeltest directory.
>
I found the version I think I need (4.7.4) at
http://python-qt4.sourcearchive.com/documentation/4.7.4-0ubuntu1/modeltest_8py-source.html

I have been unable to find out how to run it - so guessing I tried this.

# coding=utf8
from companyListModel import CompanyListModel
from modelTest import ModelTest
model = CompanyListModel()
tester = ModelTest(model, None)
tester.runAllTests()

This didn't initialise ModelTest

Traceback (most recent call last):
   File "testing.py", line 8, in <module>
     tester = ModelTest(model, None)
   File "D:\work\C-U-B\modelTest.py", line 41, in __init__
     self.connect( self.model, 
QtCore.SIGNAL("columnsAboutToBeInserted(const QtCore.QModelIndex&, int, 
int)"), self.runAllTests)
TypeError: type 'QtCore.QModelIndex' is not supported as a slot argument 
type

I'm way out of my depth.  (That usually means I'm about to learn 
something.)

Help needed!

Ian




More information about the PyQt mailing list