QTextEdit Ctrl + + zoomIn keyevent not working in Windows



  • Hi,

    I developed an editor using QTextEdit. In this zoomIn option is working for Ctrl + '+'. But when I press Ctrl + Shift + '=' keys zoomIn feature is not working.

    In linux by default, Ctrl +Shift +'=' is working. In windows it is not working.

    Ctrl+Shift+= is same as Ctrl ++

    I tried to capture the events in keypressEvent(QKeyEvent *e) method like this:
    @
    if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Plus)
    {
    this->zoomIn();
    qDebug()<<"key ctrl shift + pressed";
    } // not working

    // second trial
    if(e->modifiers() == Qt::ControlModifier &&e->modifiers() == Qt::ShiftModifier && e->key() == Qt::Key_Equal)
    {
    this->zoomIn();
    qDebug()<<"key ctrl shift + pressed";
    } // not working
    @

    How can I make Ctrl+shift+'=' make zoomIn in textEdit. How can I capture these keypresses combination.

    Please suggest your views on this.

    Appreciate your help in this regard.

    Thanks,
    Haney.

    }


  • I tried even the nativeScanCode() each key has a unique scan code. I cannot differentiate = and + using scan code cuz it is one key, hence same scancode.

    How to catch the combination of key press like Ctrl + Shift + '=' .

    Please give any suggestions.



  • I was able to do it this way.

    @
    Qt::KeyboardModifiers mod = QApplication::keyboardModifiers ();
    bool SHIFT = mod.testFlag(Qt::ShiftModifier);
    bool CTRL = mod.testFlag(Qt::ControlModifier);

            if (SHIFT && CTRL)
            {
                if(e->key() == Qt::Key_Plus){
    
                    qDebug()<<"now plus caught";
                    this->zoomIn();
             }
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.