Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problem with keyEvent handler



  • I've added a keyPressEvent handler to my code:

    void DSSImageWidget::keyPressEvent(QKeyEvent* e)
    {
        QPointF mouseLocation(mapFromGlobal(QCursor::pos()));
        if (e->matches(QKeySequence::ZoomIn))
            zoom(mouseLocation, 1);
        if (e->matches(QKeySequence::ZoomOut))
            zoom(mouseLocation, -1);
        
        Inherited::keyPressEvent(e);
    }
    
    

    But it never calls the zoom mf! Even though I press Ctrl++ or Ctrl+-

    I also tried this in a keyReleaseEvent handler - also didn't work ...

    What am I doing wrong? Should I also call ignore() for key sequences I'm not interested in?



  • Arrgh - the problem was a case of WHICH + and - key to combine with Ctrl!

    Num-pad keys work for this, but not the regular ones



  • Arrgh - the problem was a case of WHICH + and - key to combine with Ctrl!

    Num-pad keys work for this, but not the regular ones


Log in to reply