How to set the Precision for the Decimal Values?

  • Can anyone please help me how to set the precision for the Decimal Values. In my Line Edit i can enter any number of integer values & i want to set the precision for the decimal values. When i am entering a value in Line Edit the decimal values should not exceed more than 3 decimals. How can i set the precision for this decimals values?


    Note: i have to set the Precision only for the Decimal Values.

  • Try this way...

    @QString::number( double n, char format = 'g', int precision = 3)@

  • Moderators

    Or, if you care about other nations, you can use this:
    QLocale().toString( n, 'g', 3 )

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.