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. How to reset chartview after zoom and scroll?

How to reset chartview after zoom and scroll?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • R Offline
    R Offline
    rafael
    wrote on last edited by
    #1

    I have a chartview with zoom and scroll.
    when i zoom in and scroll then hit the escape key.

    the chartview resets, but it doesnt scroll back to the original position.
    is there a function like zoomReset that reverses the scroll?

    void ChartView::keyPressEvent(QKeyEvent *event)
    {
        switch (event->key()) {
        case Qt::Key_Plus:
            chart()->zoomIn();
            break;
        case Qt::Key_Minus:
            chart()->zoomOut();
            break;
        case Qt::Key_Escape:
           chart()->zoomReset();
            break;
        case Qt::Key_Left:
            chart()->scroll(-1000, 0);
            break;
        case Qt::Key_Right:
            chart()->scroll(1000, 0);
            break;
        case Qt::Key_Up:
            chart()->scroll(0, 1000);
            break;
        case Qt::Key_Down:
            chart()->scroll(0, -1000);
            break;
        default:
            QGraphicsView::keyPressEvent(event);
            break;
        }
    }
    
    1 Reply Last reply
    2
    • ankit thakarA Offline
      ankit thakarA Offline
      ankit thakar
      wrote on last edited by
      #2

      Actually in Qt documentation it's written in the description of zoomReset() function that
      Resets the series domains to what they were before any zoom method was called.

      Which means that the series of operation should be 1) Zoom 2) Scroll right/left/up/down.
      If you perform above sequence of operation then zoomReset() will work.

      It seems that it is correct also if you have performed scroll operation first then it is also obvious that you want to analyze in scrolled Area only so zoomReset() will just then resets zooming only...

      1 Reply Last reply
      1
      • R Offline
        R Offline
        rafael
        wrote on last edited by
        #3

        thanks. managed to get it to work, by zooming in ever so slightly before scrolling.

        M 1 Reply Last reply
        2
        • R rafael

          thanks. managed to get it to work, by zooming in ever so slightly before scrolling.

          M Offline
          M Offline
          Moein_v
          wrote on last edited by
          #4

          @rafael how did you manage to do that?

          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