Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
ded2bb11
Commit
ded2bb11
authored
5 years ago
by
Victor Poughon
Browse files
Options
Downloads
Patches
Plain Diff
BUG: fix spinbox locale issue (force C locale)
parent
44005a23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
+9
-6
9 additions, 6 deletions
...les/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
with
9 additions
and
6 deletions
Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetSpinBoxes.cxx
+
9
−
6
View file @
ded2bb11
...
...
@@ -103,7 +103,8 @@ void QtWidgetSpinBox::SetValueNoSignal(int value)
int
QtWidgetSpinBox
::
valueFromText
(
const
QString
&
text
)
const
{
bool
ok
;
int
result
=
QLocale
::
system
().
toInt
(
text
,
&
ok
);
// Force C locale because OTB gui is not i18n
int
result
=
QLocale
::
c
().
toInt
(
text
,
&
ok
);
if
(
ok
)
{
return
result
;
...
...
@@ -162,7 +163,8 @@ void QtWidgetDoubleSpinBox::SetValueNoSignal(double value)
double
QtWidgetDoubleSpinBox
::
valueFromText
(
const
QString
&
text
)
const
{
bool
ok
;
double
result
=
QLocale
::
system
().
toDouble
(
text
,
&
ok
);
// Force C locale because OTB gui is not i18n
double
result
=
QLocale
::
c
().
toDouble
(
text
,
&
ok
);
if
(
ok
)
{
return
result
;
...
...
@@ -180,7 +182,9 @@ QString QtWidgetDoubleSpinBox::textFromValue(double value) const
// which leads to ugly trailing zeros for small values (e.g 1.50000)
// We use std::ostringstream because QString::arg formatting support is too limited
std
::
ostringstream
oss
;
oss
.
imbue
(
std
::
locale
(
""
));
// use system's locale for formatting
// Force C locale because OTB gui is not i18n
oss
.
imbue
(
std
::
locale
::
classic
());
// Set precision to the number of decimal digits that can be represented without change.
// Use float precision because OTB parameter is float
...
...
@@ -190,9 +194,8 @@ QString QtWidgetDoubleSpinBox::textFromValue(double value) const
// Add a trailing dot if the number is integer,
// so that int and float parameters are more visually different.
// For now this is done for all locales, even though not all locales use this
// convention for formatting decimals...
const
char
dot
=
std
::
use_facet
<
std
::
numpunct
<
char
>>
(
std
::
locale
(
""
)).
decimal_point
();
// This is an ok convention as long as we stay in C or english locale
const
char
dot
=
std
::
use_facet
<
std
::
numpunct
<
char
>>
(
std
::
locale
::
classic
()).
decimal_point
();
if
(
oss
.
str
().
find
(
dot
)
==
std
::
string
::
npos
)
{
oss
<<
dot
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment