Results 1 to 6 of 6

Thread: Mouseevents on a QwebView or WebEngineView

  1. #1
    Join Date
    Jan 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Mouseevents on a QwebView or WebEngineView

    Im new in this Forum and new to Qt .
    On a WebView I try to reimplement a MouseEvent. The Application start without a error but the qDebug message doesn't appear.
    Please check my code...


    Thanks for help
    Webtest.h
    Qt Code:
    1. #include <QWidget>
    2. #include <QWebEngineView>
    3. #include <QMouseEvent>
    4.  
    5. class WebPageMapster : public QWebEngineView
    6. {
    7. public:
    8. WebPageMapster();
    9. ~WebPageMapster();
    10.  
    11.  
    12. protected:
    13. void mousePressEvent(QMouseEvent *event);
    14. };
    To copy to clipboard, switch view to plain text mode 

    webtest.cpp
    Qt Code:
    1. WebPageMapster::WebPageMapster()
    2. {
    3. load(QUrl("http://google.ch"));
    4. resize(800,600);
    5. show();
    6.  
    7.  
    8. }
    9.  
    10. void WebPageMapster::mousePressEvent(QMouseEvent *event){
    11. if (event->button()== Qt::LeftButton){
    12. qDebug() << "Test";
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouseevents on a QwebView or WebEngineView

    Is the mousePressEvent handler called at all?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Mouseevents on a QwebView or WebEngineView

    Hi

    Yes. on a other Widget I can call the mousePressEvent()

    Best

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouseevents on a QwebView or WebEngineView

    No, I meant on the web engine view.

    I am asking because QWebEngineView overwrites the event() method (according to the documentation), so it might not call the QWidget event handlers at all.

    You can try overwriting event() yourself, checking for the mouse press there and just pass on the even after that.

    Cheers,
    _

  5. #5
    Join Date
    Jan 2015
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Mouseevents on a QwebView or WebEngineView

    I've debuged the Events on the WebEngineView.
    Only the Enter Event 10) and the ContextMenu (Event 82,68,69) Events are ermited.
    How can Implement those MouseEvents? Or is there a other solution to paint a QRubberband on the WebEngineView by Mouse?

    Best

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouseevents on a QwebView or WebEngineView

    You could check the code of QWebEngineView to see how it intercepts the mouse events.
    Maybe it uses an event filter and you could install your own "on top" of that.

    Cheers,
    _

Similar Threads

  1. Problem with MouseEvents
    By pedrohs in forum Qt Programming
    Replies: 4
    Last Post: 5th December 2014, 19:49
  2. QGraphicsProxyWidget and mouseEvents
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2010, 18:15
  3. QTableWidget mouseEvents
    By QAir in forum Qt Programming
    Replies: 6
    Last Post: 28th July 2009, 17:11
  4. qwt mouseEvents
    By halberdier83 in forum Qwt
    Replies: 7
    Last Post: 22nd April 2009, 13:37
  5. QGraphicsView mouseEvents...?
    By thill2708 in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 21:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.