Hi,
I’ve been writing some Slicer extensions using the Extension Wizard & Qt Designer, and it’s been mostly working very well. But I’m seeing a funny behavior, which I think is a bug.
I have extensions which use simple text fields – defined as a QLineEdit
using the Qt Designer, and connected to the parameter node using the SlicerParameterName
dynamic property (on the widget), which is handled by the @parameterNodeWrapper
decorator on the Parameter Node class. I’ve compared my extension’s setup code with one created fresh by the Wizard, and AFAICT I’m not doing anything special, and not dropping any important initialization.
But the text lines behave as described here – whenever a user types a character in the middle of the field, the cursor jumps to the end.
I suspect this is caused by not-careful-enough code in the GUI connection – it looks like the callback created for updating parameters from the GUI (in parameterNodeWrapper.wrapper._makeGuiToParamCallback()
updates the parameter node, but then this updates the GUI back. I suppose this is useful in some cases. But if this is done for text fields, we probably need to restore the cursor position as described in the answers to the StackOverflow question cited above.
Have others also run into this?
[Edit: Related, of course, Parameter node wrapper GUI connectors are missing for many widgets · Issue #7308 · Slicer/Slicer · GitHub – but that lists QLineEdit
as “supported”, which it mostly is]