Results 1 to 2 of 2

Thread: QTextStream::UppercaseDigits

  1. #1
    Join Date
    Feb 2006
    Location
    Bienne, Switzerland
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextStream::UppercaseDigits

    Hi, I'm trying to get a string containing a hexadecimal number to have the letters in the number in upper case instead of lower case. I use the code below.
    tagID and antennaID are both unsigned intergers.

    Qt Code:
    1. QString outStr;
    2. QTextStream tagLine(&outStr);
    3. tagLine.setNumberFlags(QTextStream::UppercaseDigits);
    4. tagLine << "TagFound: " << hex << tagID << " on Antenna: " << antennaID;
    To copy to clipboard, switch view to plain text mode 

    But the resulting string always has lower case letters in the hex number:
    "TagFound: 702f2cba on Antenna: 1"

    Any idea what i am doing wrong? thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream::UppercaseDigits

    It looks like a Qt bug:
    Qt Code:
    1. bool QTextStreamPrivate::putNumber(qulonglong number, bool negative)
    2. {
    3. QString tmp;
    4. if (negative)
    5. tmp = QLatin1Char('-');
    6. else if (numberFlags & QTextStream::ForceSign)
    7. tmp = QLatin1Char('+');
    8.  
    9. if (numberFlags & QTextStream::ShowBase) {
    10. switch (integerBase) {
    11. case 2: tmp += QLatin1String("0b"); break;
    12. case 8: tmp += QLatin1String("0"); break;
    13. case 16: tmp += QLatin1String("0x"); break;
    14. default: break;
    15. }
    16. }
    17.  
    18. tmp += QString::number(number, integerBase ? integerBase : 10);
    19. if (numberFlags & QTextStream::UppercaseBase) // <--- this is wrong
    20. tmp = tmp.toUpper(); // ### in-place instead
    21.  
    22. return putString(tmp);
    23. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jacek for this useful post:

    mightymark (12th May 2006)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.