Results 1 to 4 of 4

Thread: QLineEdit - Float number not displayed correct

  1. #1
    Join Date
    May 2006
    Posts
    9
    Thanks
    1

    Default QLineEdit - Float number not displayed correct

    Hi,

    I am using QLineEdit to display a Float number.

    When setting the the text using setText() then the number is not displayed correct.

    For example the number '9.991' is displayed '9 .991', 1 or more spaces before the decimal point! This happens when I set the input mask to ###.###;

    I tried other masks like 999.999; but same result. If I don't use a mask then it is displayed correct but then the user can enter alfanumeric characters!

    I hope someone can help me on this.

    Regards,
    Morty

  2. #2
    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: QLineEdit - Float number not displayed correct

    Have you tried without input mask and with a double validator instead?
    Qt Code:
    1. // bottom (-999.0), top (999.0), decimals (2)
    2. lineEdit->setValidator(new QDoubleValidator(-999.0, 999.0, 2, lineEdit));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Posts
    9
    Thanks
    1

    Default Re: QLineEdit - Float number not displayed correct

    Hi,

    Yes, I did try that.

    I just thought it would be neater to prevent the user entering letters. And when it is possible to have a numeric mask that should prevent this, why not use it.

    Have I misunderstood the use of the input mask?

    Regards,
    Morty

  4. #4
    Join Date
    May 2006
    Posts
    9
    Thanks
    1

    Default Re: QLineEdit - Float number not displayed correct

    I made a mistake when setting the QDoubleValidator so I could still enter letters.

    Now that I have tried again and got it right I can see that it is only possible to enter numbers.

    Problem solved.

    Morty

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.