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 get the wheel event from the qwebenginview widget?
Qt 6.11 is out! See what's new in the release blog

how to get the wheel event from the qwebenginview widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 1.5k Views 2 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1
    page()->settings()->setAttribute(QWebEngineSettings::ShowScrollBars,false);
    

    I hided the scrollbar of the qwebengineview widget.
    and I implemented the wheelEvent from the qwebengineview ,but u know it didnt work.
    I guess maybe I'm get the wrong event function.Please tips me.

    JonBJ 1 Reply Last reply
    0
    • nicker playerN nicker player
      page()->settings()->setAttribute(QWebEngineSettings::ShowScrollBars,false);
      

      I hided the scrollbar of the qwebengineview widget.
      and I implemented the wheelEvent from the qwebengineview ,but u know it didnt work.
      I guess maybe I'm get the wrong event function.Please tips me.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @nicker-player
      You migth show what you tried for the wheel event, and state what "t didnt work" means in practice. Depending you might look at the example at https://stackoverflow.com/a/69999649/489865 if it relates to your situation.

      nicker playerN 1 Reply Last reply
      0
      • JonBJ JonB

        @nicker-player
        You migth show what you tried for the wheel event, and state what "t didnt work" means in practice. Depending you might look at the example at https://stackoverflow.com/a/69999649/489865 if it relates to your situation.

        nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by nicker player
        #3

        @JonB

        bool WidgetBrowser::eventFilter(QObject *obj, QEvent *e){
            if (obj == this)   
            {
                if (e->type() == QEvent::Wheel){
                    QWheelEvent* event =(QWheelEvent*)e;
                    int det = event->angleDelta().y();
                    emit onSignalWheel(event);
                }
            }
        
            return QWidget::eventFilter(obj, e);
        }
        
        

        I put the code into the project.but the webengineview could not get the event from the webview.I dont know why.maybe it is related to the chrome framework?

        JonBJ 1 Reply Last reply
        0
        • nicker playerN nicker player

          @JonB

          bool WidgetBrowser::eventFilter(QObject *obj, QEvent *e){
              if (obj == this)   
              {
                  if (e->type() == QEvent::Wheel){
                      QWheelEvent* event =(QWheelEvent*)e;
                      int det = event->angleDelta().y();
                      emit onSignalWheel(event);
                  }
              }
          
              return QWidget::eventFilter(obj, e);
          }
          
          

          I put the code into the project.but the webengineview could not get the event from the webview.I dont know why.maybe it is related to the chrome framework?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @nicker-player
          The stackoverflow solution states and shows it is using focusProxy(), that was the whole point of it. So did you try that?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SimonSchroeder
            wrote on last edited by
            #5

            If you want to use eventFilter you need to write a different class (just derived from QObject) that has the event filter and then call installEventFilter on your instance of WidgetBrowser with an object that has eventFilter implemented.

            JonBJ 1 Reply Last reply
            0
            • S SimonSchroeder

              If you want to use eventFilter you need to write a different class (just derived from QObject) that has the event filter and then call installEventFilter on your instance of WidgetBrowser with an object that has eventFilter implemented.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @SimonSchroeder
              Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond the QWebEngineView-derived class, which I presume is the OP's WidgetBrowser. It shows exactly what they want you to try, see the use of focusProxy().....

              nicker playerN Pl45m4P 2 Replies Last reply
              0
              • JonBJ JonB

                @SimonSchroeder
                Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond the QWebEngineView-derived class, which I presume is the OP's WidgetBrowser. It shows exactly what they want you to try, see the use of focusProxy().....

                nicker playerN Offline
                nicker playerN Offline
                nicker player
                wrote on last edited by
                #7

                @JonB said in how to get the wheel event from the qwebenginview widget?:

                what to do? No other/different class, beyond the

                Ive tried the code is object->parent(),it seemed works fine.
                not the focusProxy() part.now I will tried the focusProxy() method .
                I dont understand the focusProxy usage.

                1 Reply Last reply
                0
                • JonBJ JonB

                  @SimonSchroeder
                  Have you/the OP looked at the stackoverflow link showing what to do? No other/different class, beyond the QWebEngineView-derived class, which I presume is the OP's WidgetBrowser. It shows exactly what they want you to try, see the use of focusProxy().....

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by Pl45m4
                  #8

                  @JonB said in how to get the wheel event from the qwebenginview widget?:

                  It shows exactly what they want you to try, see the use of focusProxy()

                  But don't you have to install the eventFilter somewhere in order to catch/filter the events? I think this is what @SimonSchroeder is talking about, which was not done in the StackOverflow example. IIRC the eventFilter won't receive all events just like that. Only if there's a "filtering object" set with webengine->installEventFilter(observer).
                  I'm not sure if the filter and the filtered object can be the same QObject. Never tried it.

                  Edit:
                  Never mind, the filter is installed on focusProxy() QObject...


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  JonBJ 1 Reply Last reply
                  0
                  • Pl45m4P Pl45m4

                    @JonB said in how to get the wheel event from the qwebenginview widget?:

                    It shows exactly what they want you to try, see the use of focusProxy()

                    But don't you have to install the eventFilter somewhere in order to catch/filter the events? I think this is what @SimonSchroeder is talking about, which was not done in the StackOverflow example. IIRC the eventFilter won't receive all events just like that. Only if there's a "filtering object" set with webengine->installEventFilter(observer).
                    I'm not sure if the filter and the filtered object can be the same QObject. Never tried it.

                    Edit:
                    Never mind, the filter is installed on focusProxy() QObject...

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @Pl45m4 said in how to get the wheel event from the qwebenginview widget?:

                    Never mind, the filter is installed on focusProxy() QObject...

                    Yes that was what I was drawing attention to for the OP. I don't know but the SO poster was saying mouse events (including wheel) go to focusProxy().

                    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