Results 1 to 6 of 6

Thread: QDecimalEdit - Help...!

  1. #1
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDecimalEdit - Help...!

    Can some one tell me how can i have a line edit where i show a . so that a user enter some value and it will move upto certain limit... What i am looking is something like DecimalEdit.... Which shows DOT in the lineedit and when user enter value the . is automatically adjusted...

    I am using 000000009.00; in INputMask of my line edits but they seem to not have . Automatecally adjusted..

    If possible please provie some sample code

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDecimalEdit - Help...!

    I think the easiest way is to connect to the QLineEdit::textEdited(const QString&) and adjust the text yourself and set it back every time the user types something.
    You can also change the cursor position, etc.

    You must use that signal instead of textChanged, since it is not emitted when you change the text programmatically.

    Regards

  3. #3
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDecimalEdit - Help...!

    Hey, can you provide me with some sample code..?

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

    Default Re: QDecimalEdit - Help...!

    One possibility could be to use a custom validator. Do the required adjustments in reimplemented QValidator::fixup().
    J-P Nurmi

  5. #5
    Join Date
    Jun 2007
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDecimalEdit - Help...!

    can i have some small sample code?

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

    Default Re: QDecimalEdit - Help...!

    Unfortunately I don't have anything at handy. Start with reading QValidator detailed description. Then,
    J-P Nurmi

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.