Ask a Question

How to add and identify custom Qt controls

sameerjade
Frequent Contributor

How to add and identify custom Qt controls

Hello,

I am using TestComplete to test a desktop application. Object spy catches an entire box but no objects inside of it. It is Qt based. I already tried a a couple of ways but they are not working.

 

Object spy returns this with the box selection: 

Sys.Process("Abc").....QtObject("TreeView").QtObject("qt_scrollarea_viewport")

 

First I tried adding a custom Qt control in my projects object mapping page (based on the below link). After adding the custom control and saving, object spy still can't find the inside objects.
https://support.smartbear.com/testcomplete/docs/general-info/supported-technologies/controls/qt.html

 

Then I tried using the Text Recognition Technology in TestComplete (based on the below link) by calling the TextObject method but it looks like It must use the class name returned by the WndClass property of the object and since my control is Qt object it only has QtClass and therefore it is not able to invoke the TextObject method. 

https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/text-recognition/...

 

Any ideas how we can do this for Qt controls? Thanks!

13 REPLIES 13
Marsha_R
Community Hero

Re: How to add and identify custom Qt controls

Here's the reference for testing with QT.  This should help with your troubleshooting.

https://support.smartbear.com/testcomplete/docs/app-testing/desktop/qt/index.html


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sameerjade
Frequent Contributor

Re: How to add and identify custom Qt controls

Thanks Marsha! I checked the info in this link but can't find the solution to my problem. 

 

To be more specific about the problem, we have a custom Qt control (or a derived class) which is derived from the base class "QWidget". When I go to "Object Mapping" in TestComplete, I can't find the base class "QWidget" and therefore cannot check the "derived classes" checkbox which may solve my problem. Under "Object Mapping" > "Qt Controls" > "Tree Widget", there is only one object "QTreeWidget".

Therefore my question is, how can I add my custom control or derived class which is derived from the base class "QWidget"? Or how can I make TestComplete catch the items inside of my custom control? Without this ability, my only option is to use xy coordinates on the control which makes my tests unstable and hard to maintain.

 

Thanks!

sameerjade
Frequent Contributor

Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

Hello,


I am trying to pick objects inside of a Qt control. Object spy catches the entire box but is unable to catch the objects inside of it.
Object spy returns this with the box selection:
Sys.Process("Abc").....QtObject("TreeView").QtObject("qt_scrollarea_viewport")

This is a custom Qt control (or a derived class) which is derived from the base class "QWidget". When I go to "Object Mapping" in TestComplete, I can't find the base class "QWidget" and therefore cannot check the "derived classes" checkbox which may solve my problem. Under "Object Mapping" > "Qt Controls" > "Tree Widget", there is only one object "QTreeWidget".

Therefore my question is, how can I add my custom control or derived class which is derived from the base class "QWidget"? Or how can I make TestComplete catch the items inside of my custom control? Without this ability, my only option is to use xy coordinates on the control which makes my tests unstable and hard to maintain.

I also explored the option of using the "Text Recognition Technology" in TestComplete by calling the "TextObject" method but it looks like It must use the class name returned by the WndClass property of the object and since my control is Qt object it only has QtClass and therefore it is not able to invoke the TextObject method. Is there a way to use the "Text Recognition Technology" with Qt objects?

Thanks in advance!

Marsha_R
Community Hero

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

Since they are the same question, I combined your two posts here.

 

Let's see a screenshot of your object mapping where the qt items are.


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sameerjade
Frequent Contributor

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

Attaching screenshot of my Object Mapping window:

 

sameerjade_0-1629752840788.png

 

Marsha_R
Community Hero

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

And what happens when you try to add your custom control?


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sameerjade
Frequent Contributor

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

I tried adding the custom control in 2 ways:

 

1. First I tried adding a custom control "TreeWidget" under Qt Controls>Tree widget. After saving changes, I try to select my control using object spy but there is no change. It still cannot highlight the items inside my control.

2. Second I tried the first approach in the below link i.e. find your custom control's base class in the object mapping window and select the "derived classes" checkbox. This enables TestComplete to find your derived classes/custom controls from that base class. However, my base class is "QWidget" and this base class is not listed in the Object Mapping window, therefore I cannot do this approach.

https://smartbear-cc.force.com/portal/KbArticleViewer?name=TestComplete-doesn-t-recognize-items-in-m...

 

Please let me know if I am missing something. Thanks!

Marsha_R
Community Hero

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

What type is your QWidget?


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sameerjade
Frequent Contributor

Re: Unable to access a derived class (or custom qt control) which is derived from the QWIDGET class

I am not sure about that. How can I find that out? When I select my control with the object spy, it gives QtClassName=QWidget (see attached screenshot from object spy). It does not give the type of QWidget.

I will check with my developers also.

 

sameerjade_0-1629756084144.png

 

cancel
Showing results for 
Search instead for 
Did you mean: