installEventHandler

installEventHandler(eventName, handlerFunctionName)

installEventHandler(className, eventName, handlerFunctionName)

installEventHandler(object, eventName, handlerFunctionName)

These functions install an event handler that is applied to all objects of the className class, or to the specified object, or globally (if no className or object is specified). The script function named in handlerFunctionName (which can be passed as a string or as a function reference), will be called when an event of the eventName type occurs on an object of the className class, or to the specified object, or globally.

The eventName can be the name any standard Qt event type such as QKeyEvent event or QMouseEvent, or one of the Squish convenience event types listed below:

  • Crash: This event occurs if the AUT crashes.
  • DialogOpened: This event occurs when a top-level QDialog is shown.
  • MainWindowOpened: This event occurs when a top-level QMainWindow is shown.
  • MessageBoxOpened: This event occurs when a top-level QMessageBox is shown.
  • Timeout: This event occurs when the Squish response timeout is reached.
  • ToplevelWidgetOpened: This event occurs when any other kind of top-level widget is shown.

The function named in handlerFunctionName is called with a single argument—the object on which the event occurred.

Note: In Python scripts, you can specify the callback function to invoke by passing an actual function or a lambda function.

For examples, see How to Use Event Handlers.

Note: The installEventHandler function will only work if it is called after the AUT has been started by using the ApplicationContext startApplication(autName) function, for example.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results