Change Installer UI Example
Change Installer UI demonstrates how to use the Component()
function to modify the default text for the radio button labels on the license check page. This example does not install any components, but we specify a dummy component in the package information file, because installers without components are not allowed.
<?xml version="1.0" encoding="UTF-8"?> <Installer> <Name>Change Installer UI Example</Name> <Version>1.0.0</Version> <Title>Change Installer UI Example</Title> <Publisher>Qt-Project</Publisher> <StartMenuDir>Qt IFW Examples</StartMenuDir> <TargetDir>@HomeDir@/IfwExamples/changeuserinterface</TargetDir> </Installer>
- The
<Default>
element specifies whether the component is preselected for installation in the user interface by default. - The
<Script>
element specifies the file name of the JavaScript file that is loaded to perform operations. - The
<Licenses>
element specifies thename
of the license agreement to be accepted by the end user and the filename of thefile
that contains the license.
<?xml version="1.0" encoding="UTF-8"?> <Package> <DisplayName>Dummy Component</DisplayName> <Description>This example does not install any components. It demonstrates modifying the text on the next page.</Description> <Version>1.0.0-1</Version> <ReleaseDate>2013-01-01</ReleaseDate> <Default>true</Default> <Script>installscript.qs</Script> <Licenses> <License name="Beer Public License Agreement" file="license.txt" /> </Licenses> </Package>
Modifying UI Text
In installscript.qs, we call the Component()
function to add the license check page and to connect to the changeLicenseLabels
signal when end users enter the page:
function Component() { gui.pageWidgetByObjectName("LicenseAgreementPage").entered.connect(changeLicenseLabels); }
We use the changeLicenseLabels
function to change the text labels for the accept and reject license radio buttons on the page:
changeLicenseLabels = function() { page = gui.pageWidgetByObjectName("LicenseAgreementPage"); page.AcceptLicenseLabel.setText("Yes I do!"); page.RejectLicenseLabel.setText("No I don't!"); }
Note: Do not use the Component()
function to add translations.
Files:
- changeuserinterface/config/config.xml
- changeuserinterface/packages/org.qtproject.ifw.example.changeuserinterface/meta/installscript.qs
- changeuserinterface/packages/org.qtproject.ifw.example.changeuserinterface/meta/license.txt
- changeuserinterface/packages/org.qtproject.ifw.example.changeuserinterface/meta/package.xml
- changeuserinterface/changeuserinterface.pro