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.0k 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 5 Dec 2019, 05:17 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 1 Reply Last reply 5 Dec 2019, 05:59
    0
    • A Ayush Gupta
      5 Dec 2019, 05:17

      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 Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 5 Dec 2019, 05:59 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 5 Dec 2019, 06:14 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);

        J 1 Reply Last reply 5 Dec 2019, 06:16
        1
        • A Ayush Gupta
          5 Dec 2019, 06:14

          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);

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 Dec 2019, 06:16 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 5 Dec 2019, 06:31 last edited by
            #5

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

            J 1 Reply Last reply 5 Dec 2019, 06:51
            0
            • A Ayush Gupta
              5 Dec 2019, 06:31

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 5 Dec 2019, 06:51 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

              1/6

              5 Dec 2019, 05:17

              • Login

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