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. QTextEdit Accessibility doesn't work!

QTextEdit Accessibility doesn't work!

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 544 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.
  • P Offline
    P Offline
    payman
    wrote on last edited by
    #1

    I have a simple GUI with a single QTextEdit. I want to change the text of textEdit object whenever some keys pressed by user.

    The problem is that when I change the text using QTextEdit::setText(), it seems that screen reader receives no event at all and therefore it doesn't read the new text for user.

    I have tried QTextEdit::Update(), QtextEdit::setFocus(), QAccessibleTextUpdateEvent and QAccessible::updateAccessibility(), but none of them works!

    My event filter code is like this :

    bool MainWindow::eventFilter(QObject *watched, QEvent *event)
    {
        if(watched == ui->textEdit && event->type() == QEvent::KeyPress)
        {
            QKeyEvent *key_event = static_cast<QKeyEvent *>(event);
            QString str = "Hello! " + QString::number(counter++);
            if(key_event->key() == Qt::Key_Down)
            {                    
                ui->textEdit->setText(str);
    
                return true;
            }
        }
    
        return false;
    }
    

    Also I've noticed that if I change the cursor position after changing the text, then screen reader reads the new text!

    My code to change cursor position :

    bool MainWindow::eventFilter(QObject *watched, QEvent *event)
    {
        if(watched == ui->textEdit && event->type() == QEvent::KeyPress)
        {
    
            QKeyEvent *key_event = static_cast<QKeyEvent *>(event);
            QString str = "Hello! " + QString::number(counter++);
            if(key_event->key() == Qt::Key_Down)
            {
                int pos =  ui->textEdit->textCursor().position();
    
                ui->textEdit->setText(str);
    
                if( pos == 0)
                {
                    ui->textEdit->moveCursor(QTextCursor::End);
                }
                else
                {
                    ui->textEdit->moveCursor(QTextCursor::StartOfLine);
                }
                return true;
            }
        }
    
        return false;
    }
    

    But the above code works only with KEY_DOWN and if I change the key to something else then Orca goes silent again!!!

    Any idea to solve this issue?

    I'm using QT 5.10, Ubuntu 16.04 and Orca 3.25.90 .

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      I knew about the issues on Windows but not on Linux.

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1

      • Login

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