I have a scene which has a basically table-like layout. Thus I'd like it to scroll like a table... one row or column at a time. Specifically, the upper left visible item should have it's upper left corner in the upper left corner of the viewport, unless the scrollbars are at their maximum (in which case it is the bottom/right item that is exactly in view). Pressing an arrow key should display the next row or column in that direction.

Normally that is easily achievable by inheriting QAbstractScrollArea and setting it up as appropriate, but QGraphicsView already does this. Is there someone who can think of a clever method for achieving this effect?

link|flag

1 Answer

just override QGraphicsScene::keyPressEvent and...

  • right: move a cells width in positive x
  • left: move a cells width in negative x
  • up: move a cells height in negative y
  • down: move a cells height in positive y

you'll have to disable this movement at the ends of the table, but it sounds a lot simpler that you might have initially thought

link|flag

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.