xTuple.com xTupleU Blog & News Customer Support

QPlainTextEdit

I am sorry for putting in so many tickets on xTuple 5 but we have a lot of customization to do.

I created a QPlainTextEdit box in the Screen Editor and want to limit the text to digits and decimals only.

So I select the ImhFormattedNumbersOnly box and save to database and file.
Curiously , the ImhNone is also selected and can not be un selected.

Reviewing the file showed that the ImhFormattedNumbersOnly was not added to the property, only the ImhNone.

So I change the xml in the file to ImhFormattedNumbersOnly and import and Property Editor has not changed.

But the code in the uiform table shows ImhFormattedNumbersOnly.

So I test the screen and I can enter letters in the textbox

So in my script I add

policy.inputMethodHints = 8192; // set to numbers only, I think

and save and test and I still can add letters to the QPlainTextEdit box

is this a known bug and is there a workaround?

Thank you

Why are you using the PlainTextEdit widget? That is typically used for multi-line text input (i.e. notes).

There are a few X widgets which we have provided that give you enhanced functionality.

I would use something like XLineEdit for numerical entry. You can then define it as a numbers only by setting a validator:
_mywidget.setValidator(mainwindow.qtyVal());

This restricts entry of data to predefined numerical values. In the above example I have restricted the numbers to the Quantity validator as defined in System->Settings->Locale. You can see a bunch of numeric validators of different decimal precision in the Locale settings. Or you can define your own validator if those patterns do not fit.

Ok thank you once again Anderson

I will go to the line edit