Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. reading textEdit when QEvent::KeyPress is called
Qt 6.12 LTS is out! See what's new in the release blog

reading textEdit when QEvent::KeyPress is called

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 384 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.
  • mhsgoudM Offline
    mhsgoudM Offline
    mhsgoud
    wrote on last edited by
    #1

    Hi, I am trying to read the textedit text whenever a new entry is added. I use:

        if(event->type() == QEvent::KeyPress ){
            QKeyEvent *kevent = static_cast<QKeyEvent *>(event);
    
             QString uu = ui->textEdit->toPlainText();
             qDebug() << uu ;
            }
    

    uu does not include the latest key entry. seems the value of textEdit is not readily updated when this event occurs, and there is some sort of delay...

    C 1 Reply Last reply
    0
    • mhsgoudM mhsgoud

      Hi, I am trying to read the textedit text whenever a new entry is added. I use:

          if(event->type() == QEvent::KeyPress ){
              QKeyEvent *kevent = static_cast<QKeyEvent *>(event);
      
               QString uu = ui->textEdit->toPlainText();
               qDebug() << uu ;
              }
      

      uu does not include the latest key entry. seems the value of textEdit is not readily updated when this event occurs, and there is some sort of delay...

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      The character corresponding to the key press (if there is one) may not be inserted in to the buffer until the key release event.

      Is the QTextEdit::textChanged() signal not a better solution to detecting change in the editor?

      1 Reply Last reply
      3

      • Login

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