Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Remove traling zeros from QString scientific notation num value
Qt 6.12 LTS is out! See what's new in the release blog

Remove traling zeros from QString scientific notation num value

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
3 Posts 3 Posters 687 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LiamEvans210
    wrote on last edited by
    #1

    I have the next code, this code print a value in scientific notation, but i want to remove the trailing zeros

    valor = 541; QString cStyleResult = QString::number(valor.toDouble(), 'e');

    qDebug() << cStyleResult ;

    //////////////////////////////////////////////
    output: 5.410000e2

    I want to remove the trailing zeros(right decimal zeros), example I want to save only the value of 5.41

    some ideas????

    Ringtones free: https://ringtonesfree.info/

    Christian EhrlicherC jsulmJ 2 Replies Last reply
    0
    • L LiamEvans210

      I have the next code, this code print a value in scientific notation, but i want to remove the trailing zeros

      valor = 541; QString cStyleResult = QString::number(valor.toDouble(), 'e');

      qDebug() << cStyleResult ;

      //////////////////////////////////////////////
      output: 5.410000e2

      I want to remove the trailing zeros(right decimal zeros), example I want to save only the value of 5.41

      some ideas????

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @LiamEvans210 Search for the 'e', remove all before it until it's != '0'

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • L LiamEvans210

        I have the next code, this code print a value in scientific notation, but i want to remove the trailing zeros

        valor = 541; QString cStyleResult = QString::number(valor.toDouble(), 'e');

        qDebug() << cStyleResult ;

        //////////////////////////////////////////////
        output: 5.410000e2

        I want to remove the trailing zeros(right decimal zeros), example I want to save only the value of 5.41

        some ideas????

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @LiamEvans210 You could also specify the precision (third parameter in QString::number()).

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved