On Aug 22, 2011, at 4:57 PM, Ben Breslauer wrote: > Hi, > > I think these are bugs but I'm not sure, so, in case I'm doing something > wrong, I'm emailing first. I am using Python 2.7.2, PySide 1.0.5, Qt 4.7.3, > and ArchLinux with kernel 3.0.3. > > I'm porting an application from PyQt4, and the code works as intended there. > I'm trying to create a table by subclassing QAbstractTableModel and using > QTableView. When I minimally implement QAbstractTableModel (just > implementing rowCount, columnCount, data, headerData, and flags) the > resulting table is not how I would expect it to look (again, based on my > experiences with PyQt4). > > First, each cell has a checkbox in it, even though I have not requested that > the cells be checkable, nor is the data boolean values. I cannot find any > setCheckable-like method to use with the model or view, and flags() never > includes Qt.ItemIsUserCheckable.
I've run into the same issue. You may not realize it, but each cell also has a blank icon. I've gone chasing through the documentation and gotten nowhere. You have re-implemented data() -- you will find that returning None for roles 1 and 10 (icon and check state, respectively) eliminate the display of the checkbox and the empty space for the non-existent icon. If you use something like QSqlRelationalTableModel for the model those roles seem to already be handled, but if you are subclassing you must deal with them yourself. I find some aspects of Qt's model/view/delegate counterintuitive and I am a complete noob, but as far as I can tell the appropriate place to handle this problem -- when subclassing QAbstractTableModel at any rate -- is in the implementation of data(). If that is indeed the case it would be nice for it to be documented. The PySide docs say you must implement rowCount(), columnCount() and data() -- but it doesn't give any hint as to what the implementation of data() might need to handle. Just a brief statement that an implementation of data() must account for each of the roles (with a link to the page enumerating them) would be helpful for those unfamiliar with Qt. Tim Doty _______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside