Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. rubberband zooming in QGraphicsView
Qt 6.11 is out! See what's new in the release blog

rubberband zooming in QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    seok
    wrote on last edited by
    #1

    hi community,

    somebody help me how to zoom the area selected by rubberband

    After setting the drag mode to rubber band drag in QGraphicsview
    setDragMode(QGraphicsView::RubberBandDrag)
    how to zoom the area selected by the rubber band

    Thanks in advance

    1 Reply Last reply
    0
    • S Offline
      S Offline
      seok
      wrote on last edited by
      #2

      here is the code i have tried so far
      but after this i dont know how to make that selected area zoom

          ui->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

      JonBJ 1 Reply Last reply
      0
      • S seok

        here is the code i have tried so far
        but after this i dont know how to make that selected area zoom

            ui->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

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @seok
        There are lots of Google hits for qgraphicsview 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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved