Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to replace function `QWheelEvent::angleDelta()` in android for zoom in / zoom out function?
Forum Updated to NodeBB v4.3 + New Features

How to replace function `QWheelEvent::angleDelta()` in android for zoom in / zoom out function?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 391 Views 1 Watching
  • 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.
  • I Offline
    I Offline
    ishi
    wrote on 6 Sept 2022, 09:12 last edited by ishi 9 Jun 2022, 09:20
    #1

    I was using the angleDelta() function from the QWheelEvent class to achieve the zoom in, zoom out. While using on windows, wheelEvent worked fine to zoom in and out by scrolling the mouse wheel.

    void MapView::wheelEvent(QWheelEvent *event)
    {
        if(event->angleDelta().y() > 0)
        {
            if(m_scale < MAX_SCALE)
            {
                std::cout << m_scale << std::endl;
                this->scale(ZOOM_STEP, ZOOM_STEP);
                m_scale *= ZOOM_STEP;
            }
        }
        else if(event->angleDelta().y() < 0)
        {
            if(m_scale >= MIN_SCALE)
            {
                std::cout << m_scale << std::endl;
                this->scale(1/ZOOM_STEP, 1/ZOOM_STEP);
                m_scale *= 1/ZOOM_STEP;
            }
        }
    }
    

    Now I am trying to run it in AVD and I don't want to use a mouse to zoom in and out. Looking for a solution to zoom in and out on android in the QT app.

    M 1 Reply Last reply 7 Sept 2022, 13:13
    0
    • I ishi
      6 Sept 2022, 09:12

      I was using the angleDelta() function from the QWheelEvent class to achieve the zoom in, zoom out. While using on windows, wheelEvent worked fine to zoom in and out by scrolling the mouse wheel.

      void MapView::wheelEvent(QWheelEvent *event)
      {
          if(event->angleDelta().y() > 0)
          {
              if(m_scale < MAX_SCALE)
              {
                  std::cout << m_scale << std::endl;
                  this->scale(ZOOM_STEP, ZOOM_STEP);
                  m_scale *= ZOOM_STEP;
              }
          }
          else if(event->angleDelta().y() < 0)
          {
              if(m_scale >= MIN_SCALE)
              {
                  std::cout << m_scale << std::endl;
                  this->scale(1/ZOOM_STEP, 1/ZOOM_STEP);
                  m_scale *= 1/ZOOM_STEP;
              }
          }
      }
      

      Now I am trying to run it in AVD and I don't want to use a mouse to zoom in and out. Looking for a solution to zoom in and out on android in the QT app.

      M Offline
      M Offline
      mvuori
      wrote on 7 Sept 2022, 13:13 last edited by
      #2

      You just need to add some control in your UI that you can use to get absolute values that represent the zoom range, or some signals that represent zoom in & zoom out.

      Just add a scrollbar, two buttons, capture swipe, or something else that fits in the UI design.

      1 Reply Last reply
      0

      1/2

      6 Sept 2022, 09:12

      • Login

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