[Qt-interest] QGraphicsItem ignore scene translation/transform?

Samuel Rødal samuel.rodal at nokia.com
Mon Jan 25 11:47:05 CET 2010


ext Thomas Fjellstrom wrote:
> Ok, I think I've got a plan now that just might work.
> 
> Manually draw the board with a single "Smarter" widget that handles its own 
> internal translation and transformation.
> 
> To do that I'd need to either not add the board square items to the board, 
> and then draw each one manually when I think it might be dirty, or do the 
> same, but make the BoardSquare's a plain QObject (instead of a 
> QGraphicsWidget subclass ). Either way aught to work, and would result in 
> the same api for the BoardSquares (paint()). Going either route is 
> essentially the same, and would allow me to change very little in the 
> existing BoardSquare class.
> 
> But it does mean I have to handle ALL hit testing and updating of the 
> BoardSquares manually. Which I was trying really hard not to have to do.

Couldn't the "Smarter" widget still just be a top-level graphics item 
with a lot of children? Then set the scene rect to be static and handle 
scrolling by translating the top-level graphics item (based on some 
custom input handler).

The other option I could see to avoid having to write a fully custom 
widget would be to embed a sub-graphics view into the main graphics view.

> Is a feature where an item is completely isolated from the scene 
> transformation and translation likely to be added to Qt? I think it would be 
> something that a lot of people would like very much.

I guess the use case of having scroll bars that only scrolled some of 
the graphics items was not considered to be important. Maybe it breaks 
user expectations of how scroll bars typically work, so having a 
different way of scrolling based on mouse or keyboard input (grouping 
all the scrollable items in a graphics item) might actually be preferable.



More information about the Qt-interest-old mailing list