QDoubleSpinBox and decimal place
-
I have a QDoubleSpinBox on a form, the inputMethodHints is set to ImhFormattedNumbersOnly. In my class I have the keyPrevvEvent and I can see when the dot is pressed the event is received, however for some reason unknown to me, the control doesn't accept the dot, so if I type in 12.3 I only see 123.
Why ?
-
Hi,
What locale are you using ? Did you check if it does the same using
,
rather that.
? -
Hi
Just for fast test, i tried to change it here
and it gladly accepts the "." now. ( and rejects ",")I would check what keycode ACR890 sends for that key.
-
I've tried that, it doesn't fix it for me...the interesting thing is that the keyPressEvent does get the dot event when pressed and it shows a key value of 16777268, if I press any of the number keys, none of these are displayed in the keyPressEvent routine but they are excepted by the control.
-
What keyboard are you using ?
-
Its the ACR890, a card reader:
https://www.acs.com.hk/en/products/372/acr890-all-in-one-mobile-smart-card-terminal/
I've tried several locale's now including UnitedKingdom, UnitedStates and HongKong, the problem exists with all of those.
-
Does it happen on the device itself or your getting inputs from the device to your computer ?
-
Sorry, I don't really understand what you are asking, I'm using Qt Creator to deploy the application to the target, I'm using the device directly when I push the following:
1 2 . 3
On the display I see only:
123
If I monitor in Qt Creator with a breakpoint in keyPressEvent, only pressing:
.
Results in a call to the routine, pressing any of the numbers does not. The routine receives and event with the key returned as:
16777268
-
No, nothing I just dropped it in from the palette on the left, changed the geometry and font size and that is all.
Looking at the object in Qt Creator, to be precise, this is what I've changed:
geometry [(10,40), 221 x 51] font A [Ubuntu, 24] alignment AlignHCenter, AlignVCenter maximum 99999999.990000 singleStep 0.010000
In the class prototype:
void keyPressEvent(QKeyEvent* pEvent); private slots: void on_spbxAmount_valueChanged(const QString& strText);
The implementation for the above:
void clsSaleForm::keyPressEvent(QKeyEvent* pEvent) { int intKey = pEvent->key(); qDebug() << intKey; } void clsSaleForm::on_spbxAmount_valueChanged(const QString& strText) { bool blnNothing = (strText.isEmpty() || strText.toDouble() == 0); ui->pbtnNext->setEnabled(!blnNothing); }
I just tried to replicate this behaviour on my iMAC, created with the same settings and it worked perfectly, so it must be an issue with the version of Qt on the Ubuntu build.
On my iMAC I'm using:
Qt Creator 4.9.1 Based on Qt 5.12.3 (Clang 10.0 (Apple), 64 bit) Built on May 26 2019 21:14:16 From revision 168e91b618
And on the laptop running Ubuntu 14.04:
Qt Creator 3.0.1 Based on Qt 5.2.1 (GCC 4.8.2, 32 bit) Built on Apr 9 2014 at 09:14:10
Sadly I cannot upgrade the Ubuntu Qt as the SDK I'm using is part of the ACR SDK and there doesn't appear to be an update.
-
Hi
Ah, you overrode forms keypress, not the QDoubleSpinBox's.
thats why you saw . and not 1,2,3.Are you 100% sure you set locale on the QDoubleSpinBox since its
not shown in modifications? -
ok. just checking
so a normal QLineEdit will get the "." ?