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 can I ignore horizontally QWheelEvent?(for mouse pad)
Forum Updated to NodeBB v4.3 + New Features

How can I ignore horizontally QWheelEvent?(for mouse pad)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.1k 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.
  • ardaozdemirA Offline
    ardaozdemirA Offline
    ardaozdemir
    wrote on last edited by
    #1

    I use QWheelEvent for zoom in/out on GraphicsScene but the problem is that zoom in/out is also working when I use mouse pad horizontally. I want to ignore this situation. I want to do zoom in/out on mouse pad just vertically.

    My code is:

    void WheeledGraphicsView::wheelEvent(QWheelEvent *event){
            setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
            double scaleFactor = 1.15;
            if(event->delta() > 0) {
                scale(scaleFactor, scaleFactor);
            }
            else {
                scale(1.0 / scaleFactor, 1.0 / scaleFactor);
            }
           // QWheelEvent.orientation();
    }
    
    

    maybe I can use QWheelEvent::orientation() but I couldn't use it. thank you !

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome

      code shows
      // QWheelEvent.orientation();

      but I assume you did mean

      event->orientation(); ?

      Why cant you use it ?

      ardaozdemirA 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi and welcome

        code shows
        // QWheelEvent.orientation();

        but I assume you did mean

        event->orientation(); ?

        Why cant you use it ?

        ardaozdemirA Offline
        ardaozdemirA Offline
        ardaozdemir
        wrote on last edited by
        #3

        @mrjj Hi,

        actually I don't understand how can I ignore horizontally wheelevent using QWheelEvent::orientation(). So I couldn't it bcs of I don't understand.

        thank you.

        mrjjM 1 Reply Last reply
        0
        • ardaozdemirA ardaozdemir

          @mrjj Hi,

          actually I don't understand how can I ignore horizontally wheelevent using QWheelEvent::orientation(). So I couldn't it bcs of I don't understand.

          thank you.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @ardaozdemir
          ok.

          Can you check if its different for horizontally versus vertically "wheeling"
          ?

          just qDebug() the value

          1 Reply Last reply
          0
          • ardaozdemirA Offline
            ardaozdemirA Offline
            ardaozdemir
            wrote on last edited by
            #5

            okey I solved the problem.

            void WheeledGraphicsView::wheelEvent(QWheelEvent *event){
                if(event->orientation() == Qt::Horizontal) {
                    event->ignore();
                }
                else {
                    if(event->delta() > 0) {
                        scale(ZOOM_RATIO_PER_WHEEL_TICK, ZOOM_RATIO_PER_WHEEL_TICK);
                    }
                    else {
                        scale(1.0 / ZOOM_RATIO_PER_WHEEL_TICK, 1.0 / ZOOM_RATIO_PER_WHEEL_TICK);
                    }
                }
            }
            

            thank you.

            1 Reply Last reply
            1
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              So I assume it did have the right value :)
              please mark as solved if possible.

              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