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. How convert int to string with 2 fields?
Forum Updated to NodeBB v4.3 + New Features

How convert int to string with 2 fields?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 736 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.
  • E Offline
    E Offline
    Enrique82
    wrote on last edited by
    #1

    I need to convert numbers to string, but with 2 fields, for examples:

    If int num=1, I need Qstring txt = "01"
    If int num=23, I need Qstring txt = "23"

    Thanks

    J.HilkJ 1 Reply Last reply
    0
    • E Enrique82

      I need to convert numbers to string, but with 2 fields, for examples:

      If int num=1, I need Qstring txt = "01"
      If int num=23, I need Qstring txt = "23"

      Thanks

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @enrique82

      that's like super easy to google 🤔
      https://stackoverflow.com/questions/2618414/convert-an-int-to-a-qstring-with-zero-padding-leading-zeroes

      QString number = QString("%1").arg(yourNumber, 2, 10, QChar('0'));
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • E Offline
        E Offline
        Enrique82
        wrote on last edited by
        #3

        Thanks, I couldn't find it in google

        Pablo J. RoginaP 1 Reply Last reply
        0
        • E Enrique82

          Thanks, I couldn't find it in google

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @enrique82 if your issue is solved, please don't forget to mark your post as such! Thanks

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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