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.
TestComplete provides access to non-windowed components of Qt applications the same way it provides access to windowed components. You can explore alien widget controls in the Object Browser, work with their properties and call their methods in your tests.
Alien widgets of a Qt application can become windowed during testing. This happens because 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 can occur during the test execution.
There are two 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 full names to address Qt controls in tests.
If you still want to use alien widgets in your Qt applications, it is recommended that you use the full names of Qt controls to address them in your tests. For example, if you use variables to refer to Qt controls and the Unable to find the object error occurs during the script run, insert a script line that obtains the required Qt control again before the script line where the error occurs.
Note: To access alien widget controls in tests, you can use the
QtObjectmethod and specify the needed object by using the
QtIndexproperty. If creation of non-windowed controls is disabled, Qt objects will be specified by the window’s current front-to-back onscreen position (using the z-order index). These indexes cannot coincide with the
QtIndexvalues used earlier, so, you may need to modify your tests to use the
Indexproperty to address objects.