QtObject Method

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

Use this method to obtain a scripting interface to the specified object of a Qt application. The resulting object contains both methods and properties defined in application code as well as methods, properties and actions provided by TestComplete.

Declaration

TestObj.QtObject(ObjName)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ObjName [in]    Required    String    
Result Object

TestObj.QtObject(ClassName, Text)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ClassName [in]    Required    String    
Text [in]    Required    String    
Result Object

TestObj.QtObject(ClassName, Text, WndIndex)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ClassName [in]    Required    String    
Text [in]    Required    String    
WndIndex [in]    Required    Integer    
Result Object

Applies To

The method is applied to the following objects:

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

ObjName

The name of the desired object as it is specified in the tested application’s source code (the string that is returned by object’s native objectName property).

ClassName

The window’s class name as it is specified by the QtClassName property.

Text

The window’s caption as it is specified by the QtText property. You can use wildcards (* and ?) in this parameter.

WndIndex

The meaning of this parameter depends on whether the specified Qt control is windowed or non-windowed. For windowed Qt controls, the parameter specifies the window’s current front-to-back onscreen position (similar to z-order) relative to the other windows with the same ClassName of the same parent TestObj. For non-windowed controls, the parameter specifies the window’s index as it is specified by the QtIndex property.

Result Value

The QtObject method returns an object that provides a scripting interface to an object located in the tested Qt application. If TestComplete cannot access the specified object (for example, this object does not exist), the method will return an empty stub object and post an error message to the test log. You can determine whether the returned object is valid using its Exists property. This property returns False if the returned object is empty, that is the call to QtObject was not successful.

Remarks

The returned object contains both methods and properties defined in the application code as well as methods, properties and actions provided by TestComplete. The resulting object may contain two or more methods and properties having the same name. To avoid naming conflicts, use the NativeQtObject namespace.

The method is available only if the Qt Application Support plugin is installed and enabled. Otherwise, the method is absent in the method list of the TestObj object. If the plugin is installed and enabled, you cannot use the Window method to address windows of your Qt applications, you should use QtObject instead.
You can determine whether the plugin is installed using the IsPluginInstalled Method method.

Example

To view an example that demonstrates how to use the QtObject method, see Addressing Objects in Qt Applications.

See Also

Addressing Objects in Qt Applications
Object Browser Naming Notation
Using Namespaces
About Open Applications
QtClassName Property (Qt Application Objects)
WaitQtObject Method
WaitWindow Method

Highlight search results