[PyKDE] [PyQt3] alignment issue on subclassed QTableItem
Dave S
eric3 at pusspaws.net
Thu Sep 7 22:57:00 BST 2006
On Thursday 07 September 2006 22:24, Hans-Peter Jansen wrote:
> 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
Pedantic is good :)
I am learning all the time and looking at how you guys get round problems is
all good
Dave
More information about the PyQt
mailing list