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. QWebView Mouse click on scroll bar
Qt 6.11 is out! See what's new in the release blog

QWebView Mouse click on scroll bar

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

    Setup:

    I have created a "MyWebView" class by inheriting from QWebView. I have also re-implemented the "mouseDoubleClikEvent()" of QWebView in which enlarged webview widget will be opened[working fine].
    By default MyWebView will load the page "google.com" and if user double click on the web view it loads "wikipedia.com". This is working as expected.

    Issue:

    If I double click on any of the scroll bar or double click on the arrows associated with these scroll bars then I can see that the "mouseDoubleClikEvent" is getting executed.

    Is there anyway I can prevent this calling on "mouseDoubleClikEvent" when user clicks on ScrollBars? I want the "mouseDoubleClikEvent" should get called only if user double clicks inside the webview.

    Sample code:

    mywebview.h
    @
    #ifndef MYWEBVIEW_H
    #define MYWEBVIEW_H

    #include <QtWebKit/QWebView>

    class MyWebView : public QWebView
    {
    Q_OBJECT

    public:
    MyWebView(QWebView *parent = 0);
    ~MyWebView();

    protected:
    void mouseDoubleClickEvent(QMouseEvent *event);
    };

    #endif // MYWEBVIEW_H
    @

    mywebview.cpp
    @
    #include "mywebview.h"
    #include <QWebFrame>

    MyWebView::MyWebView(QWebView *parent)
    : QWebView(parent)
    {
    setUrl(QUrl("http://google.co.in"));
    }

    MyWebView::~MyWebView()
    {

    }

    void MyWebView::mouseDoubleClickEvent(QMouseEvent *event)
    {
    setUrl(QUrl("http://wikipedia.org"));
    }

    @

    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