I have a WIP that I came up with today. calculator.js (2.5 KB)
It allows you to set 4 different widgets, and an SQL statement. this helps us some. so any screen we want to convert from uom A to uom B and put the result into a box, all that is needed is 1 line edit and 2 combo boxes. I used it already as such
init(_convertInput, // LineEdit that I put the input into
_convertFrom, // XcomboBox for the From uom dropdown
_convertTo, // XcomboBox for the To uom dropdown
_qtyEdit, // The line edit that I want the output to go to.
"SELECT item_id AS result FROM coitem JOIN itemsite ON(itemsite_id = coitem_itemsite_id) "
+ "JOIN item ON (item_id = itemsite_item_id) WHERE coitem_id = <? value('keyid')?>");
//the sql statment can be null if your passing an item ID to the newId() method shown later
Then later on I select items from an xtree widget. and I connect the newId signal to the newId slot in calculator
For my case the results XTreeWidget has id's for coitemid. so my coitem_id replaces <? value('keyid')?> above.
Now the only hard part is making the query to get the item id and placing the 3 custom buttons into the desired screens.
One thing that may be possible is to use the same line edit
50 is the input
ea is the uom from
ls is the uom to
55.85 is the output field.
the combo boxes populate automatically with the script