Starting from version 4.4.0, Qt introduces alien widgets. Alien widgets are non-windowed components that do not have window handles associated with them.
You can access non-windowed components of Qt applications in the same way you access windowed components. You can explore alien widget controls in the TestLeft UI Spy, work with their properties and call their methods from tests.
Alien widgets of a Qt application can become windowed during testing. This happens because Microsoft Active Accessibility sends the
WM_GETOBJECT message to the top-level window of the tested Qt application’s process. In this case, the objects that correspond to alien widgets become non-existent and the object hierarchy of the tested Qt application changes. As a result, errors may occur in tests.
There are several ways to avoid this issue.
Disable creation of non-windowed Qt controls before testing
You can do this in one of the following ways:
Compile the QtGui and QtGuid modules without the
#define QT_NO_ACCESSIBILITYline. This will disable accessibility support and all the controls will be windowed.
QT_USE_NATIVE_WINDOWSenvironment variable to 1 to disable the use of alien widgets in Qt applications.
Qt::AA_NativeWindowsattribute on your application. This attribute ensures that the widgets of your Qt application have native windows.
Qt::WA_NativeWindowattribute on widgets in your Qt application. This attribute ensures that native windows are created for widgets and their ancestors.
QWidget::winIdmethod for widgets in your Qt application. This method forces native window creation for widgets and returns the window handle.
Use multiple criteria to identify Qt controls in tests
To access alien widget controls in tests, use the
QtPatternobject and identify the needed object by using its
If you disable creation of non-windowed controls, TestLeft will use the window’s current front-to-back onscreen position (its z-order index) to identify Qt objects in applications. These indices may differ from
QtIndexvalues. We recommend that you use the
Indexproperty to identify objects.