Important: Please read the Qt Code of Conduct -

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

  • 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";  }
            currentTab()->page()->setZoomFactor(currentTab()->zoomFactor() + 0.1);
            qDebug()<<"ZoomIn Wheel";}

    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?

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

Log in to reply