Form Editor - Scripts
There are three kinds of scripts used with forms:
- Slots – scripts intended to respond to certain events of the form or in the controls, they have a separate group in the properties of the object with slots:
- User-defined methods of the form.
To access the form object from within the script the keyword this is used, for example:
All controls of the form are accessible as the properties of the form:
name = this.cboName.currentText;
It is possible to define custom properties for the form objects, they are shared between the form scripts:
this.cboName.myProp = "prop1";
It is possible to execute one form from another, get data from it:
import '/UserDetails' as dlg; if( dlg.exec() ) this.cboUser.currentIndex = this.cboUser.ids.indexOf( dlg.getUserAddedId() );
It is possible to use script objects in forms.
For example, utility functions used in multiple forms can be imported into a button slot:
// tbEmail: QToolButton - clicked import '/Scripts/base64' const buf = this.report.printToBuffer( REPORT_PRINT_TYPE.TO_PDF ); const b64 = base64ArrayBuffer( buf );
Script objects can be used to define the startup script – script which is executed at the project opening.
For example, this script can automatically show a form when the user opens a project, to work with forms like with the standalone applications.