Results 1 to 11 of 11

Thread: QLineEdit with money format

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Sep 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit with money format

    I needed the same thing in my program. Here is the code that i think help you to figure this out. By using
    Qt Code:
    1. Util::addToRd("57836", QChar('.'), 3)
    To copy to clipboard, switch view to plain text mode 
    you can convert 57836 to 57.836
    Qt Code:
    1. QString Util::reverse(QString what)
    2. {
    3. int len = what.length();
    4. QString buffer;
    5. int i;
    6. for(i=0; i<len ; i++)
    7. buffer[i]=what[len-i-1];
    8. return buffer;
    9. }
    10.  
    11. QString Util::addToRd(QString what, QChar add, int kdabir)
    12. {
    13. QString buffer = reverse(what);
    14. int len = what.length();
    15. int sira;
    16. int deviation=0;
    17. for(sira=kdabir; sira<len ;sira=(sira+(1*kdabir)) )
    18. {
    19. buffer.insert(sira+deviation, add);
    20. deviation++;
    21. }
    22. return reverse(buffer);
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by ocean; 11th September 2008 at 21:53.

Similar Threads

  1. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  2. Replies: 2
    Last Post: 20th March 2008, 14:37
  3. Is there a known problem with QMimeData on Mac OS X?
    By Wurgl in forum Qt Programming
    Replies: 8
    Last Post: 27th February 2008, 22:21
  4. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48
  5. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25

Tags for this Thread

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.