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:
// vertical_scroll is the slot that gets called
// ival comes from valueChanged(int)
void my_graphics_item::vertical_scroll(int ival)
{
int top = pgraphicsview->viewport()->rect().top();
this->moveBy(0, top);
this->update();
}
// vertical_scroll is the slot that gets called
// ival comes from valueChanged(int)
void my_graphics_item::vertical_scroll(int ival)
{
int top = pgraphicsview->viewport()->rect().top();
this->moveBy(0, top);
this->update();
}
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
Bookmarks