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. QListWidget: Vertical Scroll Bar and Mouse Wheel
Forum Updated to NodeBB v4.3 + New Features

QListWidget: Vertical Scroll Bar and Mouse Wheel

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 2.6k 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.
  • Y Offline
    Y Offline
    yannickBAT
    wrote on last edited by yannickBAT
    #1

    Hi all,

    I am currently designing a general properties Editor in which one contains a QListWidget (for storing different type of data).

    So the QListWidget is inside the widget Editor.

    I would have thought that using the mouse wheel above the QListWidget would automatically drag the vertical scroll bar, but it doesn't. I don't know why. And I can't figure it out.

    I tried to re implement a "QListWidgetPlus" inheriting QListWidget and add my how "wheel mouse action" method, but it still wasn't working.

    bool QListWidgetPlus::eventFilter(QObject *obj, QEvent *event)
    {
      if (event->type() == QEvent::Wheel)
      {
          QWheelEvent *wEvent = (QWheelEvent *)event;
     
     wEvent->delta()>0 ? verticalScrollBar()->setValue(verticalScrollBar()->value() + 1)
                       : verticalScrollBar()->setValue(verticalScrollBar()->value() - 1) ;
      }
      return false;
    }
    

    So I resume : I have a QListWidget (inside an Editor) and I would like that this list widget scrolls down as soon as I use the mouse wheel.

    Do you know how to do this ? What am I missing ?

    Thank you in advance for your time. :-)

    raven-worxR 1 Reply Last reply
    0
    • Y yannickBAT

      Hi all,

      I am currently designing a general properties Editor in which one contains a QListWidget (for storing different type of data).

      So the QListWidget is inside the widget Editor.

      I would have thought that using the mouse wheel above the QListWidget would automatically drag the vertical scroll bar, but it doesn't. I don't know why. And I can't figure it out.

      I tried to re implement a "QListWidgetPlus" inheriting QListWidget and add my how "wheel mouse action" method, but it still wasn't working.

      bool QListWidgetPlus::eventFilter(QObject *obj, QEvent *event)
      {
        if (event->type() == QEvent::Wheel)
        {
            QWheelEvent *wEvent = (QWheelEvent *)event;
       
       wEvent->delta()>0 ? verticalScrollBar()->setValue(verticalScrollBar()->value() + 1)
                         : verticalScrollBar()->setValue(verticalScrollBar()->value() - 1) ;
        }
        return false;
      }
      

      So I resume : I have a QListWidget (inside an Editor) and I would like that this list widget scrolls down as soon as I use the mouse wheel.

      Do you know how to do this ? What am I missing ?

      Thank you in advance for your time. :-)

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @yannickBAT
      why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.
      Depending on the size of the scroll area increasing the value by 1 might not be noticable.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      Y 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @yannickBAT
        why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.
        Depending on the size of the scroll area increasing the value by 1 might not be noticable.

        Y Offline
        Y Offline
        yannickBAT
        wrote on last edited by
        #3

        @raven-worx said in QListWidget: Vertical Scroll Bar and Mouse Wheel:

        @yannickBAT
        why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.

        I handle the wheel event myself because it doesn't work (and I don't know why) for my QListWidget which is inside a bigger QGraphicsProxyWidget.

        So as it didn't work, I decided to handle it myself this way.

        Depending on the size of the scroll area increasing the value by 1 might not be noticable.

        I'll try with higher values, then!

        Thank you

        raven-worxR 1 Reply Last reply
        0
        • Y yannickBAT

          @raven-worx said in QListWidget: Vertical Scroll Bar and Mouse Wheel:

          @yannickBAT
          why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.

          I handle the wheel event myself because it doesn't work (and I don't know why) for my QListWidget which is inside a bigger QGraphicsProxyWidget.

          So as it didn't work, I decided to handle it myself this way.

          Depending on the size of the scroll area increasing the value by 1 might not be noticable.

          I'll try with higher values, then!

          Thank you

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @yannickBAT said in QListWidget: Vertical Scroll Bar and Mouse Wheel:

          my QListWidget which is inside a bigger QGraphicsProxyWidget

          well thats some crucial information no?
          Does your QGraphicsView show scrollbars?

          I'll try with higher values, then!

          simply check if it is called at all first (e.g. with a debug print).

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          Y 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @yannickBAT said in QListWidget: Vertical Scroll Bar and Mouse Wheel:

            my QListWidget which is inside a bigger QGraphicsProxyWidget

            well thats some crucial information no?
            Does your QGraphicsView show scrollbars?

            I'll try with higher values, then!

            simply check if it is called at all first (e.g. with a debug print).

            Y Offline
            Y Offline
            yannickBAT
            wrote on last edited by VRonin
            #5

            well thats some crucial information no?

            Yes. This is why I was trying to explain when I said:

            So I resume : I have a QListWidget (inside an Editor) and I would like that this list widget scrolls down as soon as I use the mouse wheel.

            on my first message. I should have told that this Editor was a QGraphicsProxyWidget, though. Sorry about that.

            Does your QGraphicsView show scrollbars?

            It does. And I can move the scroll bar manually with a mouse click and mouse move. Looks like it:

            0_1525848876600_47da232e-fc0c-45d2-97c3-51c45a91ff33-image.png

            simply check if it is called at all first (e.g. with a debug print).

            As you assumed, my event filter function is not called at all.

            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