Why do my widgets always get names like MyWidget34 rather than more descriptive names?

Squish tries to create the most descriptive names for GUI objects. By default is uses the QObject name. If this property isn't unique (or is empty), other possibly unique properties are examined (window caption, button text, etc.) before falling back to <ObjectType><num>.

One solution (and probably the best!) to get better names in generated scripts is to give all the widgets descriptive, short and unique QObject names in the AUT's source code.

If the custom widgets have other possibly unique properties, like a label, etc., Squish can be told to try using these properties. For example, suppose that we have a custom widget called CanvasView which has a unique label property. To tell Squish about this, create a file called, for example, myinit.tcl that contains the following line:

setUniqueProperty CanvasView label

Then tell Squish to interpret this file at startup:

squishrunner --config addInitScript Qt <absolute_path>/myinit.tcl

After doing this, Squish will attempt to use the CanvasView's label property for identification if its value is unique. See also, Configuring squishrunner.

© 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.