Results 1 to 2 of 2

Thread: help with.. numeric mask....

  1. #1

    Default help with.. numeric mask....

    Hi,

    Somebody have any idea about how to mask number in qlinedit, i did check the qt mask but i need something different.
    In a qlineedit field, the user input 9349894.00 and i need to show this like 9,349,894.00 after the user move to the next field.
    Thanks for anybody who wants to answer this question and help!!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: help with.. numeric mask....

    I'm afraid this is not possible to do within designer unless you're happy with setting an input mask. In code, you could catch focus out event and and apply a localized number when appropriate, for example like this:
    Qt Code:
    1. // MyLineEdit inherits QLineEdit and reimplements QWidget::focusOutEvent()
    2. void MyLineEdit::focusOutEvent(QFocusEvent* event)
    3. {
    4. QLineEdit::focusOutEvent(event);
    5.  
    6. bool ok = false;
    7. double real = text().toDouble(&ok);
    8. if (ok)
    9. setText(QLocale(QLocale::English).toString(real, 'f', 2));
    10. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. error: expected unqualified-id before numeric constant
    By Pragya in forum Qt Programming
    Replies: 28
    Last Post: 9th February 2020, 21:39
  2. QLineEdit and input mask
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 9th May 2014, 20:47
  3. MainWindow mask
    By SirBabyface in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2007, 16:12
  4. numeric value problem...
    By ocascante in forum Qt Tools
    Replies: 3
    Last Post: 2nd July 2007, 18:25
  5. Problem with mask and validation
    By gunhelstr in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 09:07

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.