Hey,
I've a problem:
Every time, my "main"-item hits another, my QGraphicsView should "scroll" to / center on my main-item: (y-coord)
if(!scene()->collidingItems(this).isEmpty())
{
emit newKollision(positiony);
}
if(!scene()->collidingItems(this).isEmpty())
{
emit newKollision(positiony);
}
To copy to clipboard, switch view to plain text mode
VerticalScrollBar = this->verticalScrollBar();
QObject::connect(mouse,
SIGNAL(newKollision
(int)),
this,
SLOT(ScrollBarSetValue
(int)));
VerticalScrollBar = this->verticalScrollBar();
QObject::connect(mouse, SIGNAL(newKollision(int)), this, SLOT(ScrollBarSetValue(int)));
To copy to clipboard, switch view to plain text mode
void GraphWidget::ScrollBarSetValue(int value)
{
VerticalScrollBar->setValue(value-400);
}
void GraphWidget::ScrollBarSetValue(int value)
{
VerticalScrollBar->setValue(value-400);
}
To copy to clipboard, switch view to plain text mode
VerticalScrollBar->scroll(...., ...) doesn't work -> there appears a gray background, when I call this function.
This works well, but there is no smooth scrolling to the y-position of the item, of course...
So, has anybody an idea, how to implement smooth scrolling on a QGraphicsView, if I want to set my y-value in the application (no MouseEvent)
Thanks
Bookmarks