Results 1 to 6 of 6

Thread: Newline char combination in qstring

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newline char combination in qstring

    QString::arg() and QString::number() take parameters such as field length and fill character. If you want a comma instead of a dot, QLocale::toString() might be handy.

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Newline char combination in qstring

    Well, here is my test code:
    Qt Code:
    1. tmpOrder.iMerchandizeID=1;
    2. tmpOrder.iMerchandizeQuantity=25;
    3. tmpOrder.rMerchandizePrice=4.00;
    4. tmpOrder.rSubtotal=tmpOrder.iMerchandizeQuantity*tmpOrder.rMerchandizePrice;
    5. tmpOrder.strMerchandizeName=QString("Testni Artikel");
    6. tmpOrder.strDisplayString=QString::number(tmpOrder.iMerchandizeID)+strMerchandizeSpaceDelimiter+\
    7. QString(tmpOrder.strMerchandizeName)+strMerchandizeDelimiter+\
    8. QString::number(tmpOrder.rMerchandizePrice, 'f', iMerchandizePricePrecision)+strMerchandizeSpaceDelimiter+\
    9. QString::number(tmpOrder.iMerchandizeQuantity)+strMerchandizeSpaceDelimiter+\
    10. QString::number(tmpOrder.rSubtotal, 'f', iMerchandizePricePrecision);
    To copy to clipboard, switch view to plain text mode 
    Now the float values (price per unit and subtotal) are ok, but as you can see I do not use .arg function.
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newline char combination in qstring

    But you use QString::number() which is exactly the same.

Similar Threads

  1. Char array[6] to QString and display it
    By arunvv in forum Newbie
    Replies: 11
    Last Post: 12th March 2014, 20:48
  2. Char Array to QString
    By 3nc31 in forum Qt Programming
    Replies: 2
    Last Post: 25th November 2007, 22:18
  3. QString to unsigned char *
    By darksaga in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2007, 07:52
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  5. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 20:49

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
  •  
Qt is a trademark of The Qt Company.