QGraphicsView with auto-scrolling

  • Hi all

    In my program I have an QGraphicsView (with scene), and many QGraphicsPixmap items, that are much smaller than the view. Items are movable via ItemIsMovable flag. But when a user moves item out the viewport, it doesn't scroll so the moving item remains fully visible. How do I implement this functionality? Please, include working source code. I'm using Qt 4.7.

    Thanks ahead

  • Homework assignment? Forums aren't for 'helping' other people by posting the source code. Forums are for helping people by pointing them in the right direction.

    Somewhere you'll get drag events. Maybe you can mock something up with the ensureVisible() functions.

  • 'ensureVisisble' can't be called every time the item received mouseMove event - the program crashes (it seems to be a stack overflow exception). Actually I have tested all available functions which described in help: ensureVisible (crashes), centerOn (crashes), setSceneRect, translate (does not work because of automatic alignment, which I cannot turn off - confirmed bug), used scroll bars (same problem as translate) - none of them give desirable or at least acceptable results. I'm asking for WORKING source code because I tried to post other forums, and people suggest the functions described above. Also I hope that somebody had already solved this problem and he would share his solution which works (I suggest that auto-scrolling is very common problem).

  • Also when just set an ItemIsMovable flag, and drag my item outside the viewport area, I encounter many error warnings in QtCreator saying: "QPainter.<some_qpainter_method>: painter not active, aborting>. What abous this problem?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.