Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLable Data format nice looking
Forum Updated to NodeBB v4.3 + New Features

QLable Data format nice looking

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 339 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    Marco Flad
    wrote on last edited by Marco Flad
    #1

    image Viwer Link

    want to replace the incoming data with max 4 digit with dashes in the above image ,my problem is I can't keep "KPH" on position when the
    the incoming data is loss than 4 digit . , when data is 4 digit all is prefect .

    code

    ui->fovspeedlabel->setText("SPD              "+QString::number(Speed)+" KPH");
    

    thank you ,

    Pl45m4P 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi,

      You can use QString::arg, set the field size to 4 and a space for filling when the number is smaller.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Marco Flad

        image Viwer Link

        want to replace the incoming data with max 4 digit with dashes in the above image ,my problem is I can't keep "KPH" on position when the
        the incoming data is loss than 4 digit . , when data is 4 digit all is prefect .

        code

        ui->fovspeedlabel->setText("SPD              "+QString::number(Speed)+" KPH");
        

        thank you ,

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #2

        @Marco-Flad

        Use more than one label and layouts?!


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        2
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi,

          You can use QString::arg, set the field size to 4 and a space for filling when the number is smaller.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • M Offline
            M Offline
            Marco Flad
            wrote on last edited by
            #4

            the second solution is better for me because my string contain chars in "abc" and must have a constant position.
            Thank you @Pl45m4 , thank you @SGaist

            1 Reply Last reply
            0

            • Login

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