[Paraview-developers] Locale settings in PV
Lodron, Gerald
Gerald.Lodron at joanneum.at
Fri Oct 16 10:31:58 EDT 2015
Hi
I searched "DoubleValidator" in complete PV source and also found same usage in other classes.I am currently not in office but you can easily search with Visual studio or other programms. Or wait till end next week.
I teseted the Qlocator::setDefault function in a constructor of a plugin of mine to set PV locale to english but no success.may it must be called directly in main before first qt stuff
Best regards
Von Samsung Mobile gesendet
-------- Ursprüngliche Nachricht --------
Von: Cory Quammen
Datum:16.10.2015 16:20 (GMT+01:00)
An: "Lodron, Gerald"
Cc: "Paraview User (paraview at paraview.org)" ,"Paraview Developer (Paraview-developers at paraview.org)"
Betreff: Re: [Paraview-developers] Locale settings in PV
Hi Gerald,
Thanks for your report and fix.
It looks like pqDoubleEdit is used only in the PointSprite plugin. Are you seeing this problem only in the PointSprite plugin, or do you see problems more widely in ParaView?
Thanks,
Cory
On Thu, Oct 15, 2015 at 5:46 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at<mailto:Gerald.Lodron at joanneum.at>> wrote:
Hello
I noticed a bug in paraview on parsing double values in QLineEdits, e.g. in pqDoubleEdit:
double pqDoubleEdit::value()
{
QString currentText = this->text();
int currentPos = this->cursorPosition();
QDoubleValidator dvalidator(NULL);
QValidator::State state = dvalidator.validate(currentText, currentPos);
if (state == QValidator::Acceptable || state == QValidator::Intermediate)
{
return currentText.toDouble();
}
return 0.0;
}
The Problem is that QDoubleValidator uses the current locale. If the current locale is e.g. German that e.g. "0.1" is not allowed, only "0,1". On the other side the QString function toDouble cannot parse it correctly, see documentation http://doc.qt.io/qt-5/qstring.html#toDouble , here the http://doc.qt.io/qt-5/qlocale.html#toDouble is recommended.... So all QLineEdit functions with toDouble must be replaced by
QLocale oL;
Double dValue = oL.toDouble( lineEdit->text())
Nasty....Other solution would be to set the locale to English for whole paraview regardless to the system locale, but I don't know if that is possible (also not very beautiful)...
Best regards
------------------------------------------------------------------------------------
Gerald Lodron
Researcher of Machine Vision Applications Group
DIGITAL - Institute for Information and Communication Technologies
JOANNEUM RESEARCH Forschungsgesellschaft mbH
Steyrergasse 17, 8010 Graz, AUSTRIA
phone: +43-316-876-1751<tel:%2B43-316-876-1751>
general fax: +43-316-876-1751<tel:%2B43-316-876-1751>
web: http://www.joanneum.at/digital
e-mail: gerald.lodron at joanneum.at<mailto:gerald.lodron at joanneum.at>
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Search the list archives at: http://markmail.org/search/?q=Paraview-developers
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview-developers
--
Cory Quammen
R&D Engineer
Kitware, Inc.
More information about the Paraview-developers
mailing list