That's simply typo on line 12. Thanks.
Added after 5 minutes:
Corrected:
--------------
double _Heading = 35.5;
_Stream.
setRealNumberNotation(QTextStream::FixedNotation);
_Stream.setRealNumberPrecision(2);
_Stream.setPadChar('0');
_Stream <<
"HDG: " <<
QTextStream::ForcePoint << _Heading;
std::cout << "_Stream: " << _qs.toUtf8().constData() << std::endl;
double _Heading = 35.5;
QString _TextForDisplay;
QTextStream _Stream(&_TextForDisplay);
_Stream.setRealNumberNotation(QTextStream::FixedNotation);
_Stream.setRealNumberPrecision(2);
_Stream.setFieldAlignment(QTextStream::AlignRight);
_Stream.setPadChar('0');
_Stream << "HDG: " << QTextStream::ForcePoint << _Heading;
QString _qs = *(_Stream.string());
std::cout << "_Stream: " << _qs.toUtf8().constData() << std::endl;
To copy to clipboard, switch view to plain text mode
Is the '2' prefix coming from the call on line 6?
_Stream.setRealNumberPrecision(2);
_Stream.setRealNumberPrecision(2);
To copy to clipboard, switch view to plain text mode
If so, that seems like a bug in QTextStream, right?
Added after 14 minutes:
The problem was caused by adding this:
'<< QTextStream::ForcePoint'
ForcePoint operator forces comma separators, not decimal point (poorly named operator, IMHO).
Changing to
_Stream << "HDG: " << _Heading;
_Stream << "HDG: " << _Heading;
To copy to clipboard, switch view to plain text mode
Fixes the leading '2' digit.
>>> IS THIS A BUG in QTextStream ??? <<<
Bookmarks