Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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";  }
        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



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


Log in to reply