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. Zoom In / Out with CTRL + WheelUp / CTRL - WheelDown in SimpleBrowser example
Qt 6.11 is out! See what's new in the release blog

Zoom In / Out with CTRL + WheelUp / CTRL - WheelDown in SimpleBrowser example

Scheduled Pinned Locked Moved Solved QtWebEngine
2 Posts 1 Posters 1.3k 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.
  • B Offline
    B Offline
    Belfix
    wrote on last edited by
    #1

    Hi,
    i want to use ctrl+wheelup or down to Zoom In or Zoom Out in the simplebrowser example of Qt.
    In BrowserWindow.h I ovverrided the wheelEvent :

    void wheelEvent(QWheelEvent *event) override;
    

    and in BrowserWindow.cpp:

        void BrowserWindow::wheelEvent(QWheelEvent *event)
    {
    if ( QApplication::keyboardModifiers () == Qt::CTRL)
    {
        if (event->delta() > 0){
            currentTab()->page()->setZoomFactor(currentTab()->zoomFactor() - 0.1);
            qDebug()<<"ZoomOut Wheel";  }
        else{
            currentTab()->page()->setZoomFactor(currentTab()->zoomFactor() + 0.1);
            qDebug()<<"ZoomIn Wheel";}
    
    event->accept();
    }
    

    It works... but only with the mouse over the browser... if i try to zoom with the cursors inside the webpage (i.e. the google homepage)... it doesn't work!

    Can you help me please?
    Thanks,
    BR
    Belfix

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Belfix
      wrote on last edited by
      #2

      I solved it... I used the QApplication notify system...

      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