H'llo there,

I'm trying to paint a QGraphicsItem to stay at the top edge of my view, but when I scroll the view down, the item scrolls off the view.
I have connected the vertical scroll bar valueChanged() function to call my slot:
Qt Code:
  1. // vertical_scroll is the slot that gets called
  2. // ival comes from valueChanged(int)
  3. void my_graphics_item::vertical_scroll(int ival)
  4. {
  5. int top = pgraphicsview->viewport()->rect().top();
  6. this->moveBy(0, top);
  7. this->update();
  8. }
To copy to clipboard, switch view to plain text mode 

1/ when this slot is called, why is top always 0? (the view is scrolled down, but this is always returned as 0)
2/ when I use ival instead of top, item moves down in big steps.
3/ how do I solve this issue? What am I doing wrong?

I just want the item to stay in view regardless of my scrolls (top, right, left or bottom).

Many thanks
Jean