Unsolved QTextEdit Accessibility doesn't work!
-
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 .
-
I knew about the issues on Windows but not on Linux.