Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Disabling zoom in QWebEngine under Qt 5.9.4
Forum Updated to NodeBB v4.3 + New Features

Disabling zoom in QWebEngine under Qt 5.9.4

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 1.5k 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.
  • H Offline
    H Offline
    hanzoc
    wrote on 3 Oct 2019, 06:49 last edited by
    #1

    We are running a fullscreen QWebEngine app compiled in Qt 5.9.4 for aarch64 platform with wayland+weston. Some of the devices running the app are touchscreens, which allow to interact with displayed pages (mostly custom made html templates). On the touchscreens, it's possible to zoom the page by using the pinch gesture, we would like to disable any zooming at all because all of the displayed content is made to fit fullscreen perfectly.

    I have tried many different ways without luck, the only way that works is using runJavaScript to overwrite the meta viewport tag, but I'm not really a fan of this solution as it may interfere with pages actually using some custom viewport settings.

    I have tried using setZoomFactor (which didn't work at all), adding --disable-pinch to the startup command which also didn't work, I also wanted to catch the pinch gesture event by installing an event filter on the QWebPage->focusProxy(), but it only returns basic touch events (TouchBegin,TouchEnd,TouchUpdate etc) and I don't know how to determine if it's a zooming event or not.

    We cannot change the Qt version. Is it possible in any other way than running the javascript?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Matthias Winker
      wrote on 16 Jan 2020, 10:33 last edited by
      #2

      Hello hanzoc,

      we did the following hack, it worked fine with Qt 5.9:
      src/core/render_widget_host_view_qt.cpp | 3 +++
      1 file changed, 3 insertions(+)

      diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
      index 2326dbdf..9fc68819 100644
      --- a/src/core/render_widget_host_view_qt.cpp
      +++ b/src/core/render_widget_host_view_qt.cpp
      @@ -288,6 +288,9 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
      }
      #endif // QT_NO_ACCESSIBILITY

      • // Hack: Disable pinch gesture
      • m_gestureProvider.SetMultiTouchZoomSupportEnabled(false);
      • if (GetTextInputManager())
        GetTextInputManager()->AddObserver(this);

      --
      2.19.2

      However, in Qt 5.12, this hack is not required, instead QtWebEngine understands:
      export QTWEBENGINE_CHROMIUM_FLAGS=--disable-pinch
      <start your application>

      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