sjdowling
sjdowling

Reputation: 3022

QMdiArea containing QMdiSubWindows not visible to accessibility APIs

I am working with a Qt application and trying to implement UI automation through the accessibility interface. This all works well except for the fact that this application has a QMdiArea which contains QMdiSubWindows and anything contained within these sub windows is completely opaque to the automation interface. I tried to inspect the elements through UIAVerify from the Windows SDK which shows the following:

MDI area

These subwindows contain a standard grid layout which contains standard Qt widgets. Since the heirachy here entirely consists of standard Qt widgets and all standard Qt widgets implement the accesibility interface as defined by MSAA I don't understand why all elements in the MDI area are hidden when I can freely access elements in all other areas of the GUI.

Upvotes: 1

Views: 1065

Answers (1)

Ezee
Ezee

Reputation: 4344

Probably the reason is that Qt doesn't register its controls as valid windows. All controls in Qt are painted on one canvas. It is made for optimization reasons.

Such Qt controls are called alien widgets.

Good news is that you can make Qt register all controls in Windows. The documentation states some ways to do that:

  • Use the QT_USE_NATIVE_WINDOWS=1 in your environment.
  • Set the Qt::AA_NativeWindows attribute on your application. All widgets will be native widgets.
  • Set the Qt::WA_NativeWindow attribute on widgets: The widget itself and all of its ancestors will become native (unless Qt::WA_DontCreateNativeAncestors is set).
  • Call QWidget::winId to enforce a native window (this implies 3).
  • Set the Qt::WA_PaintOnScreen attribute to enforce a native window (this implies 3).

The first one is the easiest and doesn't require recompilation of a program.

I tried it with UIAVerify and got a full tree of MDI controls.

Upvotes: 4

Related Questions