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

QTextCursor and QTextEdit



  • Simple class inherited from QTextEdit

    void XYZTextEdit::keyPressEvent(QKeyEvent *e)
    {
        QTextCursor tc = textCursor();
        tc.select(QTextCursor::WordUnderCursor);
       qDebug() << tc.selectedText();
    }
    

    When i type word "window" - i got window as expeted
    When I type word "1window" - i got 1window as expected
    When I type word "[window" - i got window - why charcter "[" is missing ???
    When I type word "win[dow" - i got dow

    Please advise how I can get word from start to end


  • Qt Champions 2019

    @aliks-os said in QTextCursor and QTextEdit:

    i got window - why charcter "[" is missing ???

    I guess because [ is not considered to be part of a word. But I don't know for sure, you can check how select() is implemented.


Log in to reply