I am trying to get some dynamics into my UI but don´t understand how the signal-slot concept of Qt works.
Below you can find an example code. Can someone show me how I take the values from widgets["txtInput"] and give it to widgets["txtOutput"]?
I use QCAD Version 3.26.4 with Qt Version 5.13.2 on Win10.
Code: Select all
// MyAction.js
// Include base class definition:
include("scripts/EAction.js");
include("scripts/WidgetFactory.js");
include("../MyScript.js");
function MyAction(guiAction){
MyScript.call(this, guiAction);
}
MyAction.prototype = new EAction();
MyAction.includeBasePath = includeBasePath;
MyAction.prototype.beginEvent=function() {
EAction.prototype.beginEvent.call(this);
var dialog = WidgetFactory.createWidget(MyAction.includeBasePath, "MyAction.ui");
// Restore the previous user data or display default values as set in Qt Designer:
WidgetFactory. restoreState(dialog);
//Display and execute the dialog:
if(!dialog.exec()){
// User hit cancel:
dialog.destroy();
EAction.activateMainWindow();
this.terminate();
return;
}
// User hit ok.
//Store the new user input.
WidgetFactory.saveState(dialog);
var widgets = getWidgets(dialog);
var input = widgets["txtInput"].text;
var output = widgets["txtOutput"].text;
this.terminate();
};
MyAction.init = function(basePath) {
var title = qsTr("MyAction");
var action = new RGuiAction(title, RMainWindowQt.getMainWindow());
action.setRequiresDocument(false);
action.setScriptFile(basePath + "/MyAction.js");
action.setStatusTip(qsTr(title));
action.setGroupSortOrder(73100);
action.setSortOrder(400);
action.setWidgetNames(["MyScriptMenu"]);
}