Call to QWidget::winId() causing accessibility to be broken in QT app



  • We have a QT application that uses the Accessibility layer for automated testing. After migrating to QT 5.2.1 we noticed that dialog boxes opened from the app are not accessibile from accessibility tools like UISpy.

    We identified the root cause to be the change that is made in the QWidget::winid() method to remove the #ifndef Q_WS_QPA. AFter commenting out this line of code that->setAttribute(Qt::WA_NativeWindow); below,
    the application is able to work fine and accessiblity hook is able to find the missing dialogs.

    One other fact about our application is that it is a hybrid app. I.e has combination of QT and MFC components. The calls causing accessibility to break are coming from QWinHost::event call.

    Can someone let me know what effect removing this line of code will have on our application?

    Before:
    The fix. You can see the dialog is missing in the tree in uispy.
    !http://oi58.tinypic.com/2gwb5oh.jpg(Missing)!
    After:
    The fix. You can see the dialog can be found in UISpy tool
    !http://oi57.tinypic.com/maebeq.jpg(working)!

    WId QWidget::winId() const
    {
    if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
    #ifdef ALIEN_DEBUG
    qDebug() << "QWidget::winId: creating native window for" << this;
    #endif
    QWidget that = const_cast<QWidget>(this);
    #ifndef Q_WS_QPA
    that->setAttribute(Qt::WA_NativeWindow);
    #endif
    that->d_func()->createWinId();
    return that->data->winid;
    }
    return data->winid;
    }

    Stack trace to winID()

            Qt5Widgetsd.dll!QWidget::winId()  Line 2272      C++
    
                QtSolutions_MFCMigrationFramework-2.8d.dll!QWinHost::event(QEvent * e)  Line 257 + 0x16 bytes      C++
                Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e)  Line 3482 + 0x15 bytes                C++
                Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e)  Line 3447 + 0x1a bytes    C++
                tabui.dll!QMfcTableauApp::notify(QObject * o, QEvent * e)  Line 640 + 0x18 bytes           C++
                Qt5Cored.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event)  Line 881 + 0x26 bytes                C++
                Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event)  Line 232 + 0x53 bytes C++
                Qt5Widgetsd.dll!QWidget::ensurePolished()  Line 9149 C++
                Qt5Widgetsd.dll!QWidget::ensurePolished()  Line 9156 C++
                Qt5Widgetsd.dll!QWidget::event(QEvent * event)  Line 8041     C++
                Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e)  Line 3482 + 0x15 bytes                C++
                Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e)  Line 3447 + 0x1a bytes    C++
                tabui.dll!QMfcTableauApp::notify(QObject * o, QEvent * e)  Line 640 + 0x18 bytes           C++
                Qt5Cored.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event)  Line 881 + 0x26 bytes                C++
                Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event)  Line 232 + 0x53 bytes C++
                Qt5Cored.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver, int event_type, QThreadData * data)  Line 1485 + 0xf bytes      C++
                Qt5Cored.dll!QCoreApplication::sendPostedEvents(QObject * receiver, int event_type)  Line 1344         C++
                qwindowsd.dll!QWindowsGuiEventDispatcher::sendPostedEvents()  Line 89      C++
                Qt5Cored.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned __int64 wp, __int64 lp)  Line 423                C++
                user32.dll!UserCallWinProcCheckWow()  + 0x144 bytes 
                user32.dll!DispatchMessageWorker()  + 0x1a7 bytes       
                Qt5Cored.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags)  Line 757                C++
                qwindowsd.dll!QWindowsGuiEventDispatcher::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags)  Line 80 + 0x15 bytes      C++
                Qt5Cored.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags)  Line 137                C++
                Qt5Cored.dll!QEventLoop::exec&#40;QFlags<enum QEventLoop::ProcessEventsFlag> flags&#41;  Line 212 + 0x3d bytes                C++
                tabui.dll!BaseProgressDialog::WaitModal()  Line 143        C++

  • Lifetime Qt Champion

    Hi,

    Since it's getting in the internals of Qt, I would recommend posting this question on the interest mailing list. You'll find there Qt's developers/maintainers (this forum is more user oriented)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.