Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextCursor and QTextEdit

QTextCursor and QTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 270 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aliks-os
    wrote on last edited by aliks-os
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • A aliks-os

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved