Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-29 Thread Wolfgang Rohdewald
On Sonntag 28 November 2010, Steve Borho wrote:
 Indeed, I found these when I started using the file, and
 checked in a fixed version here:
 
 http://bitbucket.org/tortoisehg/thg/src/tip/tortoisehg/hgqt/mo
 deltest.py

here are some more bug fixes for editable models. The patch is
against your file.

I changed the alignment checks to match 
http://qt.gitorious.org/qt/qt/blobs/4.7/tests/auto/modeltest/modeltest.cpp

-- 
Wolfgang
--- modeltest0.py	2010-11-29 11:29:19.247958003 +0100
+++ modeltest.py	2010-11-29 11:01:20.997958008 +0100
@@ -262,10 +262,7 @@
 variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.TextAlignmentRole)
 if variant.isValid():
 alignment = variant.toInt()[0]
-assert( alignment == QtCore.Qt.AlignLeft or
-alignment == QtCore.Qt.AlignRight or
-alignment == QtCore.Qt.AlignHCenter or
-alignment == QtCore.Qt.AlignJustify)
+assert( alignment == (alignment  int(QtCore.Qt.AlignHorizontal_Mask | QtCore.Qt.AlignVertical_Mask)))
 
 # General Purpose roles that should return a QColor
 variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.BackgroundColorRole)
@@ -313,7 +310,7 @@
 c = self.insert.pop()
 assert(c['parent'] == parent)
 assert(c['oldSize'] + (end - start + 1) == self.model.rowCount(parent))
-assert(c['last'] == self.model.data(model.index(start-1, 0, c['parent'])))
+assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent'])))
 
 # if c['next'] != self.model.data(model.index(end+1, 0, c['parent'])):
 #   qDebug  start  end
@@ -330,19 +327,19 @@
 c = {}
 c['parent'] = parent
 c['oldSize'] = self.model.rowCount(parent)
-c['last'] = self.model.data(model.index(start-1, 0, parent))
-c['next'] = self.model.data(model.index(end+1, 0, parent))
-remove.append(c)
+c['last'] = self.model.data(self.model.index(start-1, 0, parent))
+c['next'] = self.model.data(self.model.index(end+1, 0, parent))
+self.remove.append(c)
 
 def rowsRemoved(self, parent, start, end):
 
 Confirm that what was said was going to happen actually did
 
-c = remove.pop()
+c = self.remove.pop()
 assert(c['parent'] == parent)
 assert(c['oldSize'] - (end - start + 1) == self.model.rowCount(parent))
-assert(c['last'] == self.model.data(model.index(start-1, 0, c['parent'])))
-assert(c['next'] == self.model.data(model.index(start, 0, c['parent'])))
+assert(c['last'] == self.model.data(self.model.index(start-1, 0, c['parent'])))
+assert(c['next'] == self.model.data(self.model.index(start, 0, c['parent'])))
 
 def checkChildren(self, parent, depth = 0):
 
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-29 Thread Steve Borho
On Mon, Nov 29, 2010 at 4:35 AM, Wolfgang Rohdewald
wolfg...@rohdewald.de wrote:
 On Sonntag 28 November 2010, Steve Borho wrote:
 Indeed, I found these when I started using the file, and
 checked in a fixed version here:

 http://bitbucket.org/tortoisehg/thg/src/tip/tortoisehg/hgqt/mo
 deltest.py

 here are some more bug fixes for editable models. The patch is
 against your file.

 I changed the alignment checks to match
 http://qt.gitorious.org/qt/qt/blobs/4.7/tests/auto/modeltest/modeltest.cpp

Thanks.

http://bitbucket.org/tortoisehg/thg/changeset/c8b88546b90e

-- 
Steve Borho
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-28 Thread Vicent Mas
2010/11/28 Andreas Pakulat ap...@gmx.de:
 On 27.11.10 21:27:55, Ian wrote:

 [...]

     def rowCount(self, parent = None):
         ''' return No of rows of data. parent is a QModelIndex '''
         return len(self.view)

 This is wrong, even for table models you have to take care to return the
 right number of rows depending on the parent. That means if your model
 gets asked for the rowCount with a valid parent, you want to return 0
 (as you don't have childs under any of your rows). So check for
 parent.isValid().

     def columnCount(self, parent = None):
         ''' return number of columns. parent = QModelIndex()
            id, name, cubref, address, town, contacts
         '''
         return 6

 Basically the same here as above, though I think this is not quite as
 critical.


Hi Andreas,

Are you sure about this? Does it mean that the example given in the
page 428 of Summerfield's book is wrong?
Also I find misleading the Qt documentation regarding this subject
(right now I can only have a look to the Qt-6 docs). On one side the
QAbstractItemModel.rowCount documentation agrees with you (or
viceversa :-). But reading the Model Subclassing Reference page,
section Read-only access one can see:


rowCount()  Provides the number of rows of data exposed by the model.
These four functions must be implemented in all types of model,
including list models (QAbstractListModel subclasses) and table models
(QAbstractTableModel subclasses).

Additionally, the following functions must be implemented in direct
subclasses of QAbstractTableModel and QAbstractItemModel:

columnCount()   Provides the number of columns of data exposed by the
model. List models do not provide this function because it is already
implemented in QAbstractListModel.


Sorry if I'm missing something obvious (it wouldn't be the first time
that I've issues with the Qt documentation regarding models and views)

Vicent
-- 
Share what you know, learn what you don't.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-28 Thread Wolfgang Rohdewald
On Sonntag 28 November 2010, Steve Borho wrote:
 I found an updated version of the file here:
 
 http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-ppa/
 annotate/head:/lib/tests/modeltest.py

this still needs more updates. Mostly for editable models. Like 

-c = insert.pop()
+c = self.insert.pop()

or

-assert(c['last'] == self.model.data(model.index(start-1, 0, 
c['parent'])))
+assert(c['last'] == self.model.data(self.model.index(start-1, 0, 
c['parent'])))

also, the alignment test around line 289 seem to be too strict. 
Qt.alignLeft|Qt.alignTop
does actually align at top (try with a row containing a check box), so why 
should
it be invalid?

I am working on making my models bug free by using modeltest (although they do 
work
fine as they are) - when done I will publish my new modeltest.py

-- 
Wolfgang
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-28 Thread Steve Borho
On Sun, Nov 28, 2010 at 8:18 AM, Wolfgang Rohdewald
wolfg...@rohdewald.de wrote:
 On Sonntag 28 November 2010, Steve Borho wrote:
 I found an updated version of the file here:

 http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-ppa/
 annotate/head:/lib/tests/modeltest.py

 this still needs more updates. Mostly for editable models. Like

 -        c = insert.pop()
 +        c = self.insert.pop()

 or

 -        assert(c['last'] == self.model.data(model.index(start-1, 0, 
 c['parent'])))
 +        assert(c['last'] == self.model.data(self.model.index(start-1, 0, 
 c['parent'])))

Indeed, I found these when I started using the file, and checked in a
fixed version here:

http://bitbucket.org/tortoisehg/thg/src/tip/tortoisehg/hgqt/modeltest.py

 also, the alignment test around line 289 seem to be too strict. 
 Qt.alignLeft|Qt.alignTop
 does actually align at top (try with a row containing a check box), so why 
 should
 it be invalid?

Didn't catch that one.

 I am working on making my models bug free by using modeltest (although they 
 do work
 fine as they are) - when done I will publish my new modeltest.py

Excellent.

-- 
Steve Borho
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Ian

Hi Everyone,

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.


If I call  resizeColumnsToContents() on the view, all the columns are 
set to a very small size that shows only the check boxes. :(


I am using Python 2.7,  PyQt 4.7.4 and Windows 7 (64 bit).

I don't believe that QAbstractTableModel  can be quite that buggy.  So 
what am I doing wrong?


Anyone? Please?

Ian








___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Andreas Pakulat
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.

If it doesn't, provide sample code, without it its not really possible
to help you.

Andreas

-- 
You've been leading a dog's life.  Stay off the furniture.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Ian

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.


So here are the model and view:

# coding=utf8
#  companyListModel.py   class of CompanyList
import couchdb
from couchObject import CouchObject
import json
from PyQt4.QtCore import *   # so no internal routines starting with Q!
from PyQt4.QtGui import *
import pprint

class CompanyListModel(QAbstractTableModel,CouchObject):
''' a company list holds data from a view of Companies '''

def __init__(self):
''' initialise - read the view ready '''
CouchObject.__init__(self)
QAbstractTableModel.__init__(self)
self.view = self.loadView('by_name')

def rowCount(self, parent = None):
''' return No of rows of data. parent is a QModelIndex '''
return len(self.view)

def columnCount(self, parent = None):
''' return number of columns. parent = QModelIndex()
   id, name, cubref, address, town, contacts
'''
return 6

def data(self, index, role):
''' return data as QVariant at index.row and index.col '''
key = self.view.rows[index.row()].key
idx = index.column()
if  idx  len(key):
val = key[idx]
if val is None:
return QVariant()
return QVariant(val)
return QVariant()

def all_fields(self):
''' return list of fields in view'''
return [
'_id',
'name',
'cubref',
'street',
'town',
'contacts'
]

def headerData(self, col, orientation, role):
''' return the header data '''
if orientation == Qt.Horizontal:
tab = ['Name','Cub Ref','Street','Town','Contacts']
if col  len(tab):
return tab[col]
return None



# coding=utf8
#   companyListView - a company Listing window
import couchdb
from company import Company
from couchDbServer import Couch
from uuid import uuid4
import sys

from PyQt4.QtCore import *   # so no internal routines starting with Q!
from PyQt4.QtGui import *
from mainWindow import CubMainWindow
from companyListModel import CompanyListModel
# for testing
import pprint

class CompanyListView(CubMainWindow):
''' a window that lists Companies '''

def __init__(self, cubic, name=None, parent=None):
''' initialise CompanyListView window '''
super(CompanyListView,self).__init__(cubic,parent)
print NoteEditor initialising
self.setWindowTitle('Companies - No Company Selected')
self.cubic = cubic
self.model = CompanyListModel()
# build panel with a VBoxLayout, a QTableView on top, and a 
HBoxLayout below with two buttons


listPane = QWidget()
layout = QVBoxLayout()
# config tableView
self.tableView = QTableView()
self.tableView.setAlternatingRowColors(True)
self.tableView.setModel(self.model)
scrollArea = QScrollArea()
scrollArea.setBackgroundRole(QPalette.Light)
layout.addWidget(self.tableView)
# add buttons
addCompanyButton = QPushButton(Add Company)
removeCompanyButton = QPushButton(Remove Company)
quitButton = QPushButton(Quit)
buttonLayout = QHBoxLayout()
buttonLayout.addWidget(addCompanyButton)
buttonLayout.addWidget(removeCompanyButton)
buttonLayout.addStretch()
buttonLayout.addWidget(quitButton)
layout.addLayout(buttonLayout)
listPane.setLayout(layout)
self.setCentralWidget(listPane)
# link up headers to change order
header = self.tableView.horizontalHeader()
self.connect(header,SIGNAL(sectionClicked(int)),self.sortTable)
# link buttons
self.connect(addCompanyButton, SIGNAL('clicked()'), 
self.addCompany)
self.connect(removeCompanyButton, SIGNAL('clicked()'), 
self.removeCompany)

self.connect(quitButton, SIGNAL('clicked()'), self.accept)
QTimer.singleShot(10, self.initialLoad)

def sortTable(self,section):
''' sortTable called '''
print sortTable called

Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Baz Walter

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.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Wolfgang Rohdewald
On Samstag 27 November 2010, Ian wrote:
 So here are the model and view:

you could try to add checks to your methods like
in data():

if index.isValid():
  if role == Qt.DisplayRole:

data() will also be called with role == Qt.CheckStateRole
in which case your code returns True

or in headerData:

if role == Qt.DisplayRole and orientation == Qt.Horizontal:
return ...whatever...
else:
return QVariant()


-- 
Wolfgang
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Andreas Pakulat
On 27.11.10 21:27:55, 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

Sorry, typo :)

 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.

Ah, right I totally forgot that its been 'dropped' into /dev/null by
Nokia at the point where qtlabs was closed. Unfortunately Nokia doesn't
provide it yet at some other place. There's a copy of the last svn
version of the C++ code here:

https://projects.kde.org/projects/extragear/kdevelop/kdevplatform/repository/revisions/master/show/tests

 def rowCount(self, parent = None):
 ''' return No of rows of data. parent is a QModelIndex '''
 return len(self.view)

This is wrong, even for table models you have to take care to return the
right number of rows depending on the parent. That means if your model
gets asked for the rowCount with a valid parent, you want to return 0
(as you don't have childs under any of your rows). So check for
parent.isValid().

 def columnCount(self, parent = None):
 ''' return number of columns. parent = QModelIndex()
id, name, cubref, address, town, contacts
 '''
 return 6

Basically the same here as above, though I think this is not quite as
critical.

 def data(self, index, role):
 ''' return data as QVariant at index.row and index.col '''
 key = self.view.rows[index.row()].key
 idx = index.column()
 if  idx  len(key):
 val = key[idx]
 if val is None:
 return QVariant()
 return QVariant(val)
 return QVariant()

This can potentially throw exceptions because index may be invalid in
which case index.row() is return -1. So again check the index for
validity. Also you should only return data for role's you really want to
handle and return QVariant() for anything else, i.e. check for role ==
DisplayRole.

 def headerData(self, col, orientation, role):
 ''' return the header data '''
 if orientation == Qt.Horizontal:
 tab = ['Name','Cub Ref','Street','Town','Contacts']
 if col  len(tab):
 return tab[col]
 return None

I'm not sure about PyQt's constraints on this, but its common to return
a dummy QVariant from these functions. Oh and again the role-thing from
above applies.

And yes all of this is not documented in Qt's API docs, though its
visible in the example models that Qt ships. Maybe there's already a
bugreport open for an improvement.

Andreas

-- 
You fill a much-needed gap.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Ian

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


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Ian

On 27/11/2010 23:00, Andreas Pakulat wrote:

On 27.11.10 21:27:55, 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

Sorry, typo :)


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.

Ah, right I totally forgot that its been 'dropped' into /dev/null by
Nokia at the point where qtlabs was closed. Unfortunately Nokia doesn't
provide it yet at some other place. There's a copy of the last svn
version of the C++ code here:

https://projects.kde.org/projects/extragear/kdevelop/kdevplatform/repository/revisions/master/show/tests


 def rowCount(self, parent = None):
 ''' return No of rows of data. parent is a QModelIndex '''
 return len(self.view)

This is wrong, even for table models you have to take care to return the
right number of rows depending on the parent. That means if your model
gets asked for the rowCount with a valid parent, you want to return 0
(as you don't have childs under any of your rows). So check for
parent.isValid().


 def columnCount(self, parent = None):
 ''' return number of columns. parent = QModelIndex()
id, name, cubref, address, town, contacts
 '''
 return 6

Basically the same here as above, though I think this is not quite as
critical.


 def data(self, index, role):
 ''' return data as QVariant at index.row and index.col '''
 key = self.view.rows[index.row()].key
 idx = index.column()
 if  idx  len(key):
 val = key[idx]
 if val is None:
 return QVariant()
 return QVariant(val)
 return QVariant()

This can potentially throw exceptions because index may be invalid in
which case index.row() is return -1. So again check the index for
validity. Also you should only return data for role's you really want to
handle and return QVariant() for anything else, i.e. check for role ==
DisplayRole.


 def headerData(self, col, orientation, role):
 ''' return the header data '''
 if orientation == Qt.Horizontal:
 tab = ['Name','Cub Ref','Street','Town','Contacts']
 if col  len(tab):
 return tab[col]
 return None

I'm not sure about PyQt's constraints on this, but its common to return
a dummy QVariant from these functions. Oh and again the role-thing from
above applies.

And yes all of this is not documented in Qt's API docs, though its
visible in the example models that Qt ships. Maybe there's already a
bugreport open for an improvement.

Andreas


Thanks Andreas,
The hint about testing role in data removed the (uncheckable) check boxes,
and calling  resizeColumnsToContents() now sets the columns to the width 
(but not the window).


However, setting the number of fields to 5, still removes the headers.

Regards

Ian



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Baz Walter

On 27/11/10 23:02, Ian wrote:

On 27/11/2010 22:23, Baz Walter wrote:

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.


that link doesn't show all of the contents of the source - it's missing 
the README file. here's the relevant part:


quote

To Use the model test do the following:

1) Include the modeltest.py file in your project directory

2) Then in your source import modeltest and instantiate ModelTest
with your model so the test can live for the lifetime of your model.

For example:

from modeltest import ModelTest

self.model = QDirModel(self)
self.modeltest = ModelTest(self.model, self)

3) That is it.  When the test finds a problem it will throw an
AssertionError.  modeltest.py contains some hints on how to fix
problems that the test finds.

/quote
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Bugs galore in QAbstractTableModel???

2010-11-27 Thread Steve Borho
On Sat, Nov 27, 2010 at 9:42 PM, Baz Walter baz...@ftml.net wrote:
 On 27/11/10 23:02, Ian wrote:

 On 27/11/2010 22:23, Baz Walter wrote:

 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.

 that link doesn't show all of the contents of the source - it's missing the
 README file. here's the relevant part:

 quote

 To Use the model test do the following:

 1) Include the modeltest.py file in your project directory

 2) Then in your source import modeltest and instantiate ModelTest
 with your model so the test can live for the lifetime of your model.

 For example:

 from modeltest import ModelTest

 self.model = QDirModel(self)
 self.modeltest = ModelTest(self.model, self)

 3) That is it.  When the test finds a problem it will throw an
 AssertionError.  modeltest.py contains some hints on how to fix
 problems that the test finds.

 /quote
 ___
 PyQt mailing list    p...@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


I found an updated version of the file here:

http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-ppa/annotate/head:/lib/tests/modeltest.py

-- 
Steve Borho
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt