Uiloader Class Reference

The UiLoader JavaScript global object allows the user to load pre-defined Qt forms that define Qt widgets (generally built within Qt Designer). More...

Public Slots

static QScriptValue load (QScriptContext *context, QScriptEngine *engine)
 Takes a path to a predefined Qt widget form and loads that form. More...
 
static QScriptValue exec (QScriptContext *context, QScriptEngine *engine)
 Equivalent of QAppliction::exec for those scripts that wish to run their loaded UI as a separate app. More...
 
static QScriptValue setSvgIcon (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue dpiScale (QScriptContext *context, QScriptEngine *engine)
 Takes a DPI-independent pixel dimension (100% DPI scaling on an HD screen) and scales it to the current DPI setting. More...
 

Detailed Description

The UiLoader JavaScript global object allows the user to load pre-defined Qt forms that define Qt widgets (generally built within Qt Designer).

This allows users to build complex dialogs, using all of the pre-defined widgets that Qt4.8 supports. See Qt documentation for further details: http://qt-project.org/doc/qt-4.8.

This is an example of how to build a dialog using a predefined Qt designer file ( *.ui ) All widgets may be addressed directly, but through nested names. That is, if you have a checkbox inside a tab inside a dialog, you should address the widget as dialog.tab.checkbox Once you've figured out its name, you are allowed to modify all of its properties, plus you have access to both its signals and slots ( as well as its inherited properties, signals and slots )

This example and the predefined form are part of the installation, so it can be run in the software to see what it does. Look for lightTableExampleUsingPredefinedUI. It will display a non-modal widget that allows the adjustment of the light table settings in the camera view. Please refer to Qt documentation for the list of accessible widget properties.

function lightTableExampleUsingPredefineUI()
{
this.opacityChanged = function( digitValue)
{
this.ui.LightTableOpacityValueLabel.text = digitValue / 256.0;
preferences.setDouble("DRAWING_LIGHTTABLE_OPACITY", digitValue/256.0 );
}
this.washChanged = function( digitValue)
{
this.ui.LightTableWashValueLabel.text = digitValue / 256.0;
preferences.setDouble("DRAWING_LIGHTTABLE_WASH", digitValue/256.0 );
}
// Load the ui file (created in Qt designer)
localPath = specialFolders.resource;
System.println( localPath );
localPath += "/forms/lighttable.ui";
//System.println( localPath );
this.ui = UiLoader.load( localPath );
// Show the dialog in non-modal fashion.
ui.show();
// Modify any properties that seem interesting
this.ui.windowTitle = "Light Table Values";
this.ui.LightTableWashValueLabel.text =preferences.getDouble("DRAWING_LIGHTTABLE_OPACITY",0 );
this.ui.LightTableOpacityValueLabel.text =preferences.getDouble("DRAWING_LIGHTTABLE_WASH",0 );
this.ui.LightTableWashLabel.text ="LightTable Wash";
this.ui.LightTableOpacityLabel.text ="LightTable Opacity";
this.ui.LightTableWashSlider.minimun = 0;
this.ui.LightTableWashSlider.maximum = 256;
this.ui.LightTableWashSlider.value = preferences.getDouble("DRAWING_LIGHTTABLE_WASH",0 ) * 256;
this.ui.LightTableOpacitySlider.minimun = 0;
this.ui.LightTableOpacitySlider.maximum = 256;
this.ui.LightTableOpacitySlider.value = preferences.getDouble("DRAWING_LIGHTTABLE_OPACITY",0 ) * 256;
// Connect the sliders signals to a script defined local slot
ui.LightTableOpacitySlider.valueChanged.connect( this, this.opacityChanged);
ui.LightTableWashSlider.valueChanged.connect( this, this.washChanged);
}

Member Function Documentation

◆ dpiScale

static QScriptValue Uiloader::dpiScale ( QScriptContext *  context,
QScriptEngine *  engine 
)
staticslot

Takes a DPI-independent pixel dimension (100% DPI scaling on an HD screen) and scales it to the current DPI setting.

◆ exec

static QScriptValue Uiloader::exec ( QScriptContext *  context,
QScriptEngine *  engine 
)
staticslot

Equivalent of QAppliction::exec for those scripts that wish to run their loaded UI as a separate app.

◆ load

static QScriptValue Uiloader::load ( QScriptContext *  context,
QScriptEngine *  engine 
)
staticslot

Takes a path to a predefined Qt widget form and loads that form.

◆ setSvgIcon

static QScriptValue Uiloader::setSvgIcon ( QScriptContext *  context,
QScriptEngine *  engine 
)
staticslot