: QDoubleSpinBox( parent ),
myCleared( false )
{
+ // VSR 01/07/2010: Disable thousands separator for spin box
+ // (to avoid incosistency of double-2-string and string-2-double conversion)
+ QLocale loc;
+ loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator);
+ setLocale(loc);
+
// Use precision equal to default Qt decimals
myPrecision = decimals();
: QDoubleSpinBox( parent ),
myCleared( false )
{
+ // VSR 01/07/2010: Disable thousands separator for spin box
+ // (to avoid incosistency of double-2-string and string-2-double conversion)
+ QLocale loc;
+ loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator);
+ setLocale(loc);
+
// Use precision equal to default Qt decimals
myPrecision = decimals();
myCleared( false ),
myPrecision( prec )
{
+ // VSR 01/07/2010: Disable thousands separator for spin box
+ // (to avoid incosistency of double-2-string and string-2-double conversion)
+ QLocale loc;
+ loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator);
+ setLocale(loc);
+
setDecimals( dec );
setMinimum( min );
setMaximum( max );
*/
QString QtxDoubleSpinBox::textFromValue( double val ) const
{
- QString s = QLocale().toString( val, myPrecision >= 0 ? 'f' : 'g', qAbs( myPrecision ) );
+ QString s = locale().toString( val, myPrecision >= 0 ? 'f' : 'g', qAbs( myPrecision ) );
return removeTrailingZeroes( s );
}
*/
QString QtxDoubleSpinBox::removeTrailingZeroes( const QString& src ) const
{
- QString delim( QLocale().decimalPoint() );
+ QString delim( locale().decimalPoint() );
int idx = src.lastIndexOf( delim );
if ( idx == -1 )
QString iPart = src.left( idx );
QString fPart = src.mid( idx + 1 );
+ QString ePart = "";
+ int idx1 = fPart.lastIndexOf( QRegExp( "e[+|-]?[0-9]+" ) );
+ if ( idx1 >= 0 ) {
+ ePart = fPart.mid( idx1 );
+ fPart = fPart.left( idx1 );
+ }
- while ( !fPart.isEmpty() && fPart.at( fPart.length() - 1 ) == '0' )
- fPart.remove( fPart.length() - 1, 1 );
+ fPart.remove( QRegExp( "0+$" ) );
QString res = iPart;
if ( !fPart.isEmpty() )
res += delim + fPart;
+ res += ePart;
return res;
}
}
else if ( myPrecision < 0 ){
// Consider too large negative exponent as Invalid
- QChar e( QLocale().exponential() );
+ QChar e( locale().exponential() );
int epos = str.indexOf( e, 0, Qt::CaseInsensitive );
if ( epos != -1 ){
epos++; // Skip exponential symbol itself