Important: Please read the Qt Code of Conduct -

How to access the widget of external application.

  • Hi,

    I am trying to write GUI automation for -QT- Qt Application. The idea is to launch the application under test and the automation should be able to click on the menu items, button, slider based on the widget name. I read that if the widgets are implementing QAccessibleWidget , then external application can query for the widgets.

    Can anyone guide me how to go about this?


  • If the application is to operate on the opened widget on screen I think that a starting point would be to identify the widget that has focus on screen .With this info it is possible to access its menus and tool bars and do whatever you want to do with it.

    Hope this helps.

  • The application you're testing, is that a Qt application itself, or could it be any random application? What platform are you interested in?

  • As you said first i want to get the focus on the main application.

    Main Application Code:

    int main(int argc, char **argv)
    QApplication app (argc, argv);
    QPushButton button ("Hello world !");;

    return app.exec();



    My Test Application:
    Here i am trying to launch my main application and try to simulate the click on the push button. Code is below. I can see that the application is getting launched. But not able to get any control. Hope i am more clear this time.

    QString program = "MyApp.exe";
    QProcess *myProcess = new QProcess(this);

    myProcess->startDetached(program );
    QList<QPushButton *> list = myProcess->findChildren<QPushButton *>();
    if(list.size() == 0){
        printf("Its null :(");
        printf("Its not null :) ");


  • Judging from the way you're asking this question, I think this task is beyond your skills. I am sorry to put it so bluntly, but that's what it is.

    Instead of building this yourself, I would like to recommend you take a look at some already existing implementations. "Squish": would be an excellent candidate, of course, but there are other alternatives as well, like "Sikuli": (based on taking screen shots) and "many": others.

  • Yes Andre. I am not even a wk old in -QT- Qt. I have gone through squish before posting this thread. I wanted to learn how it works. Alteast the basic idea

    Edit: please use the proper name. It is called Qt, not QT. QT is short for QuickTime; Andre

  • What Squish does is install hooks in the Qt libraries, gaining direct access to the Qt application under test. That allows it to inspect all its properties, and trigger all slots, and send events to the application at will. A very powerful solution, but not trivial to replicate at all. KDAB's "GammaRay": application does something similar, and that application is open source.

  • And without the hooks, it does not work. Normally, you have no access to the memory of other processes (even not to child processes you start). Without this hooking, you have no chance.

  • Thanks a lot. I will check GammaRay

Log in to reply