Hi Jim, Am Donnerstag, 31. August 2006 23:42 schrieb Jim Bublitz: > > Sorry - can't help with QCheckBox/QButton. I implemented checkboxes > with pixmaps, I think because I didn't like the way the Qt checkboxes > looked and worked. > > It's fairly simple - I kept the underlying data in a list of one > tuple per row. So when loading the table from the list, I just had to > select which pixmap to assign to the cell, and then grab the table's > 'clicked' signal to respond to mouse clicks for columns with > checkboxes, and then toggle the pixmap assigned.
Nice idea, but does your approach allows to center the bitmap? IIRC the QTableItem code, bitmaps always appear left to some text, but I don't know, if the alignment() method trick can be applied here. When I was on holidays last week, I found some time to look more deeply into this issue without feeling too bad about wasting time in miniature issues. I subclassed a QWidget for the checkbox editor, where I added mouse and keyboard handlers. Now it behaves reasonably well, with only a sub minor issue left on focus handling. Qt3 tables know about two different focus styles: FollowStyle and SpreadSheet. The former paints the usual wireframe around the cell, while the latter draws a black rectangle. The problem is, it paints them on top of the table grid, and I couldn't manage it to get drawn there correctly for my CheckTableItems. I also tried to use the QTable.paintFocus(), but couldn't get the geometry right. Doing it myself, it's getting hairy: based on the viewport geometry, one has to calculate the grid coordinates taking (missing) headers into account.. Needless to say, one has to subclass QTable, too. Oh well. My current approach limits the focus painting into the cell, but the test code reveals an off by one paint deviation depending on which cell had the focus before: run the test code, move the cursor back and forth (by keyboard) in both top cells, and then inside the checkbox column. In the former case, the bottom and right part of the focus frame is missing for the checkbox column, while in the latter case, it is drawn as expected inside the cell. Funny, isn't it.. Still not completely satisfied :-[ Pedantic Pete
checktableitem.py
Description: application/python
_______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde