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 to add proper space between two strings.
Forum Updated to NodeBB v4.3 + New Features

How to add proper space between two strings.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.1k 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on last edited by
    #1

    I need to print two strings with some gap like below

    CF Test1
    MN Test2
    R Test3

    But I am unable to print Test1 , Test 2, Test 3 in same line. Indentation is not proper. Also the string CF and MN are same length but charachters appearance of MN seems longer hence also the Test1 and Test2 are also not coming in same length if i add tabs.

    Please suggest some good solution. I am using QString,

    J.HilkJ 1 Reply Last reply
    0
    • A Ayush Gupta

      I need to print two strings with some gap like below

      CF Test1
      MN Test2
      R Test3

      But I am unable to print Test1 , Test 2, Test 3 in same line. Indentation is not proper. Also the string CF and MN are same length but charachters appearance of MN seems longer hence also the Test1 and Test2 are also not coming in same length if i add tabs.

      Please suggest some good solution. I am using QString,

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

      @Ayush-Gupta

      the more important question is, how and were to do you "print" these strings?


      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
      0
      • A Offline
        A Offline
        Ayush Gupta
        wrote on last edited by
        #3

        I have a message box where I am priting this strings like below

        msg += "CF";
        msg+= " Test1";
        msg+= "\n";
        msg+= "MN";
        msg+= " Test2";
        MsgBoxInfo(msg);

        jsulmJ 1 Reply Last reply
        1
        • A Ayush Gupta

          I have a message box where I am priting this strings like below

          msg += "CF";
          msg+= " Test1";
          msg+= "\n";
          msg+= "MN";
          msg+= " Test2";
          MsgBoxInfo(msg);

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

          @Ayush-Gupta

          1. Use fixed width font
          2. Use tab (\t) instead of space

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

          1 Reply Last reply
          2
          • A Offline
            A Offline
            Ayush Gupta
            wrote on last edited by
            #5

            how to use fixed widht font? the font CF and MN can be of varying length

            jsulmJ 1 Reply Last reply
            0
            • A Ayush Gupta

              how to use fixed widht font? the font CF and MN can be of varying length

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

              @Ayush-Gupta Set font in the widget you use to show the text (https://doc.qt.io/qt-5/qwidget.html#font-prop)
              Why don't you read documentation?

              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 Extensions
              • Unsolved