Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-140504

a11y: QAccessibleText::getTextAfterOffset implementation for QTextEdit and QML TextEdit is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.11.0 FF
    • None
    • Debian testing, qtbase self-compiled from git dev as of 897034bc9361ae776de9dfb615af24daffaf3778
    • Linux/Wayland, Linux/X11

      The QAccessibleText::getTextAfterOffset implementation used for QTextEdit and the QML TextEdit is incorrect.

      For example, when trying to retrieve the next word that is fully after a specific index, the implementation currently (sometimes) return the word which includes that index instead (which is what QAccessibleText::getTextAtOffset should be doing).

      A similar problem exists for the for the QAccessibleText::getTextBeforeOffset implementation used by these text edits.

       

      Sample steps to reproduce, using the corresponding methods of the AT-SPI2 Text interface on Linux:

      1. Build and run this sample program
        #include <QApplication>
        #include <QLineEdit>
        #include <QMainWindow>
        #include <QTextEdit>
        #include <QVBoxLayout>
        
        int main(int argc, char* argv[])
        {
            QApplication a(argc, argv);
            QMainWindow w;
        
            QWidget* widget = new QWidget;
            w.setCentralWidget(widget);
        
            QVBoxLayout* layout = new QVBoxLayout(widget);
        
            layout->addWidget(new QLineEdit("Hello world"));
            layout->addWidget(new QTextEdit("Hello world"));
        
            w.show();
            return a.exec();
        }
      2. start Accerciser Accessibility Explorer ( https://gitlab.gnome.org/GNOME/accerciser )
      3. in Accerciser's treeview of the sample program's a11y hierarchy, select the object for the QTextEdit
      4. in Accerciser's IPython console, try to get some words after given indices
        In [43]: acc.queryText().getTextAfterOffset(2, 1)
        Out[43]: ('Hello', 0, 5)
        In [44]: acc.queryText().getTextAfterOffset(7, 1)
        Out[44]: ('world', 6, 11)
        

      Actual result:
      The returned words are not actually after the given offset.

      Expected result:
      Words actually completely after the given offset should be returned, or an empty string if there is no other word completely after the given offset.

      The implementation used for the QLineEdit handles this correctly, as can be seen by selecting its a11y object in step 3 instead. Then, repeating step 4 gives this:

      In [45]: acc.queryText().getTextAfterOffset(2, 1)
      Out[45]: (' ', 5, 6)
      In [46]: acc.queryText().getTextAfterOffset(7, 1)
      Out[46]: ('', -1, -1)
      

      (Whether the space character itself should be reported as a word or "hello" should be returned for acc.queryText().getTextAfterOffset(2, 1) is not matter of this ticket.)

        For Gerrit Dashboard: QTBUG-140504
        # Subject Branch Project Status CR V

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            michaelweghorn Michael Weghorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: