rubberband zooming in QGraphicsView
-
-
here is the code i have tried so far
but after this i dont know how to make that selected area zoomui->graphicsView->setInteractive(true); series = new QScatterSeries(); scene = new QGraphicsScene(this); series->append(0,1); series->append(1,2); series->append(2,3); series->append(5,4); chart = new QChart(); chart->ItemIsSelectable; chart->addSeries(series); chart->setTitle("chart"); chart->createDefaultAxes(); chart->legend()->hide(); chart->legend()->setAlignment(Qt::AlignTop); chart->setMinimumSize(700,300); scene->addItem(chart); ui->graphicsView->setScene(scene); ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
i found about rubberbandchanged() signal but dont know how to use it
-
here is the code i have tried so far
but after this i dont know how to make that selected area zoomui->graphicsView->setInteractive(true); series = new QScatterSeries(); scene = new QGraphicsScene(this); series->append(0,1); series->append(1,2); series->append(2,3); series->append(5,4); chart = new QChart(); chart->ItemIsSelectable; chart->addSeries(series); chart->setTitle("chart"); chart->createDefaultAxes(); chart->legend()->hide(); chart->legend()->setAlignment(Qt::AlignTop); chart->setMinimumSize(700,300); scene->addItem(chart); ui->graphicsView->setScene(scene); ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
i found about rubberbandchanged() signal but dont know how to use it
@seok
There are lots of Google hits forqgraphicsview rubber band zoom
. There is an old thread at https://www.qtcentre.org/threads/12836-Graphics-view-rubberband-zooming which says:Setting the drag mode as Rubberband drag, you will only be able to select items based on the selection.
To implement the zoom based on rubberband, u will need to implement ur own rubberband.
For this u need to catch the mouse events in scene or view. Based on this, once u get the rectangle after rubberbanding, u just nee to call fitInView() function.
So I don't know if this is what you had in mind. I didn't read through the other hits, but I would if that is what I wanted to achieve.