On Thursday 24 August 2006 16:58, Hans-Peter Jansen wrote: > Hi PyQties, > > I'm struggling with a strange effect in a subclassed QTableItem. For > clearness reasons, I need a centered checkbox table item without text > label.. > > First, I based my implementation on QCheckTableItem with only the paint > method reimplemented, where I centered the checkbox. This worked fine > as long as the field doesn't get any focus. Then the checkbox appears > on the left again :-(. Studying Qt's source, it revealed, that this > effect is due to a QCheckBox being created in createEditor(), which > paints that way. > > Later I based by subclass on QTableItem with all important methods > reimplemented. As you can see, I tried to circumvent the QCheckBox > alignment issue with adding a stretched hbox layout to the field, but > that approach, ugly as it is, doesn't seem to have any visual effects > at all.. > > Even funnier, using the alternate edit type QTableItem.Always in ctor, > the valueChanged(int, int) signals row/col values turn invalid > (-1, -1).. Oh well. > > Obviously I'm stuck. Searching the Qt interest archives, it appears, it > already nagged on other people brains, but doesn't provide a solution > either. > > I really hope, I do not have to reimplement QCheckBox/QButton for > getting this to work. > > May some brighter soul gives me a touch with his/her cluestick.. 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. I kept the list/tuples updated, so I didn't subclass QTableItem to hold the data. Not being able to read back the table data might be a problem in some cases, but wasn't in mine. That also allows you to do more attractive checkboxes, or use other images, like left and right arrows, or different colors to represent the binary data. Jim _______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde