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. Mouse wheel scrolling qml
QtWS25 Last Chance

Mouse wheel scrolling qml

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.4k 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.
  • M Offline
    M Offline
    mehrdad
    wrote on last edited by
    #1

    i have a code in my program that play zoom_in and zoom_out role by changing scale value of my main rectange
    i want to change plus and minus event key by mouse wheel up and down scrolling...i test delta function but this function can not detect up scrolling from down scrolling...can you help me? thanks!

    Keys.onPressed: {
           if (event.key == Qt.Key_Plus) {
               world.scale= world.scale + 0.01;
           }
           if (event.key == Qt.Key_Minus) {
               if(world.scale>0.009999999999999247)world.scale= world.scale - 0.01;
           }
    }
    
    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      If i get you correctly you want to zoom in and zoom out the rectangle using the mouse scroll. You can use MouseArea's onWheel event.
      Refer "photosurface":http://doc.qt.digia.com/qt-5.1/qtquick/demos-photosurface-photosurface-qml.html for a working example.

      157

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        You can look at the onWheel signal of MouseArea. This will help you.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mehrdad
          wrote on last edited by
          #4

          p3c0 thank you very much, i use "onwheel" but it did not detect scrolling up from down, thanks...

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            Hi,

            Check wheel.angleDelta.y it gives positive or negative value depending upon scroll direction, hence you can check it's scroll up or down.

            157

            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