Identifying Qt Objects

Applies to TestLeft 15.40, last modified on March 17, 2022
Search Patterns

To search for objects in Qt applications, you use search patterns of the QtPattern type.

.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.Qt namespace.

Java: The pattern belongs to the com.smartbear.testleft.testobjects package.

This pattern uses the following properties:

Property Type Description
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
Index Integer Used for windowed objects. The object’s position in the front-to-back order (Z-order) within the parent object. Indexes start from 1 and are unique among sibling objects with the same window class (the WndClass property value). You can see this value in the TestLeft UI Spy.
objectName String The object name specified by the developers in the application code.
QtClassName String The object’s class name, for example, QTableWidget.
QtIndex Integer Used for windowless objects. The object’s 1-based index among sibling objects of the same class.
QtText String The object caption. This is the value of the object’s text or windowTitle property.
Visible Boolean Specifies whether the object is visible in the application. Objects that are out of screen bounds or overlapped by other objects are still considered visible.
Example

C#

IQtTableWidget tableWidget = Driver.Find<IProcess>(new ProcessPattern()
{
   ProcessName = "QTableWidgetDemo"
}).Find<ITopLevelWindow>(new QtPattern()
{
   QtClassName = "MainWindow",
   QtText = "QTableWidget Demo"
}).Find<IQtTableWidget>(new QtPattern()
{
   objectName = "table1"
});

Visual Basic .NET

Dim tableWidget As IQtTableWidget = Driver.Find(Of IProcess)(New ProcessPattern() With {
   .ProcessName = "QTableWidgetDemo"
}).Find(Of ITopLevelWindow)(New QtPattern() With {
   .QtClassName = "MainWindow",
   .QtText = "QTableWidget Demo"
}).Find(Of IQtTableWidget)(New QtPattern() With {
   .objectName = "table1"
})

Java

QtTableWidget tableWidget = driver.find(TestProcess.class, new ProcessPattern() {{
   ProcessName = "QTableWidgetDemo";
}}).find(TopLevelWindow.class, new QtPattern() {{
   QtClassName = "MainWindow";
   QtText = "QTableWidget Demo";
}}).find(QtTableWidget.class, new QtPattern() {{
   ObjectName = "table1";
}});

Custom Properties

You can also specify custom properties by using the .add("propertyname", value) method of the pattern object. See Using Custom Properties in Search Patterns.

See Also

Understanding Object Identification
Preparing Qt Applications for Testing

Highlight search results