Below is basicaly what my code is for that particular part.
scene->setSceneRect(0, 0, 512, 640);
ui.graphicsView->setScene(&*scene);
void Form::scaleView(qreal scaleFactor)
{
ui.graphicsView->scale(scaleFactor, scaleFactor);
}
{
if (0 == ui.graphicsView->viewport()){
if (e
->type
() == QEvent::Wheel) {
scaleView(pow((double)2, -q->delta() / 240.0));
e->accept();
return true;
}
}
}
scene = new QGraphicsScene;
scene->setSceneRect(0, 0, 512, 640);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
ui.graphicsView->setScene(&*scene);
void Form::scaleView(qreal scaleFactor)
{
ui.graphicsView->scale(scaleFactor, scaleFactor);
}
bool Form::eventFilter(QObject *o, QEvent *e)
{
if (0 == ui.graphicsView->viewport()){
if (e->type() == QEvent::Wheel)
{
QWheelEvent *q = dynamic_cast<QWheelEvent*>(e);
scaleView(pow((double)2, -q->delta() / 240.0));
e->accept();
return true;
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks