PJH
8th June 2012, 08:15
We want a QTableWidget which overlays a rectangle around a selection - just like Excel. When a contiguous area is selection, we want a black rectangle drawn around the selection. Eventually we want to add a small square or cross to the bottom right hand corner of the bounding rectangle (again just like Excel) where the user can choose to fill down.
So far we have tried subclassing QTableWidget and reimplementing paintEvent so that QTableWidget paintEvent is called and then we get a painter from the viewpoint and draw the rectangle ourselves. This sort of works but we are hitting all sorts of issues with artefacts from previously drawn rectangles as the selection changes shape. The QTableWidget is redrawing intelligently and many of the areas are not being redrawn. The screen ends up a mess.
At the moment I feel as if I am doing things the hard way and I am hoping that someone says "Just reimplement function A".
Any ideas welcome
TIA
PHooper
Added after 16 minutes:
Why is it that, after working on something for hours, you find the solution a few minutes after asking for help? Oh well.
We were on the right track, we just had to use setDirtyRegion for the entire area of the selection rather than let QTableWidget sort it out.
It all seems so obvious now...http://www.qtcentre.org/images/smilies/redface.png Once we have cleaned up the code, I will post it in case anyone else hits the same problem.
Having said all that, if anyone has a great alternative I am more than happy to listen.
Thanks
PJH
So far we have tried subclassing QTableWidget and reimplementing paintEvent so that QTableWidget paintEvent is called and then we get a painter from the viewpoint and draw the rectangle ourselves. This sort of works but we are hitting all sorts of issues with artefacts from previously drawn rectangles as the selection changes shape. The QTableWidget is redrawing intelligently and many of the areas are not being redrawn. The screen ends up a mess.
At the moment I feel as if I am doing things the hard way and I am hoping that someone says "Just reimplement function A".
Any ideas welcome
TIA
PHooper
Added after 16 minutes:
Why is it that, after working on something for hours, you find the solution a few minutes after asking for help? Oh well.
We were on the right track, we just had to use setDirtyRegion for the entire area of the selection rather than let QTableWidget sort it out.
It all seems so obvious now...http://www.qtcentre.org/images/smilies/redface.png Once we have cleaned up the code, I will post it in case anyone else hits the same problem.
Having said all that, if anyone has a great alternative I am more than happy to listen.
Thanks
PJH