Important: Please read the Qt Code of Conduct -

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

  • 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.(

    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 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);
    Widget w;;

    return a.exec(&#41;;


  • 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 {


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

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Thanks for sharing the solution. You could consider checking the "bug report system": 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.

Log in to reply