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. Accessibility: Setting value of a QT5 Text box (LineEdit) using LDTP accessablity method settextvalue and inspect.exe tool

Accessibility: Setting value of a QT5 Text box (LineEdit) using LDTP accessablity method settextvalue and inspect.exe tool

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.7k 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.
  • B Offline
    B Offline
    bemnet4u
    wrote on last edited by
    #1

    I spent the whole weekend trying to implement accessibility for my QT5 based. My goal is to be able to set text value of a LineEdit (Text) using an LDTP settextvalue method to automate my application testing.(http://pythonhosted.org/ldtp/d9/d73/a00060.html)

    However I keep on getting the following error.
    Unhandled exception: Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

    This works fine with a win32 app. Also the Microsoft Inspect.exe tool throws the same error.

    I have tried all the options provided http://qt-project.org/doc/qt-4.8/accessible.html to achieve this. Which include.

    1. Trying to dynamically load the plugin defined in qtaccessiblewidgets.dll by putting the accessible folder in my executable deployment.
    2. Calling the QAccessible::installFactory method for the QAccessibleLineEdit control in my main.cpp. doing this. Below is a code snippet I have.

    Can someone tell me If it is possible to set value of a LineEdit control using the accessibility functionality. If there is any other way please do let me know.

    #include "widget.h"
    #include <QApplication>
    #include <QtPlugin>
    #include <QAccessibleInterface>
    #include <simplewidgets.h>

    QAccessibleInterface *lineEditFactory(const QString &classname, QObject *object)
    {
    QAccessibleInterface *interface = 0;

    if (classname == QLatin1String("QLineEdit") && object && object->isWidgetType())
    

    interface = new QAccessibleLineEdit(static_cast<QWidget *>(object));
    else if (classname == QLatin1String("QWidget") && object && object->isWidgetType())
    interface = new QAccessibleWidget(static_cast<QWidget *>(object));
    return interface;
    }

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QAccessible::installFactory(lineEditFactory);
    Widget w;
    w.show();

    return a.exec(&#41;;
    

    }

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bemnet4u
      wrote on last edited by
      #2

      Found out the root cause for this. QT doesn't have the put_acctValue method implemented yet. Added this, rebuilt the gui project and it is working.

      HRESULT STDMETHODCALLTYPE QWindowsAccessible::put_accValue(VARIANT varID, BSTR text)

      {

      showDebug(__FUNCTION__, accessible);
      
      if (!accessible->isValid())
      
          return E_FAIL;
      
         std::wstring intermediateString(text, SysStringLen(text));
      
      QString finalString = QString::fromStdWString(intermediateString);
      
      AccessibleElement elem(varID.lVal, accessible);
      
         elem.setText(Value, finalString);
      
      return S_OK;   
      

      }

      The AccessibleElement method looks like this.

      void setText(QAccessible::Text t, QString &text) const {

          if(iface)
      

      iface->setText(t, 0, text);
      }

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Thanks for sharing the solution. You could consider checking the "bug report system":http://bugreports.qt-project.org to see whether something like that has been reported. If not please open a bug report.

        You could also submit a patch for Qt so everybody can benefit. For that you must use gerrit.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

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