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. format stream output
Forum Updated to NodeBB v4.3 + New Features

format stream output

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 480 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.
  • O Offline
    O Offline
    ODБOï
    wrote on 26 Nov 2019, 09:52 last edited by ODБOï
    #1

    hi
    with this code

       qDebug()<< reMatch.captured(1)  << " : " << reMatch.captured(2)
                        << "; DIAM : " <<  reMatch.captured(3)
                        << "; LT : "  << reMatch.captured(4)
                        << "; LU : "  << reMatch.captured(5);
    

    the output is

    "T1"  :  "BOULE" ; DIAM :  "10" ; LT :  "111" ; LU :  "80"
    "T2"  :  "CYL" ; DIAM :  "11" ; LT :  "112" ; LU :  "81"
    "T3"  :  "DROIT" ; DIAM :  "12" ; LT :  "113" ; LU :  "82"
    "T4"  :  "CON" ; DIAM :  "13" ; LT :  "114" ; LU :  "83"
    

    how can i have an output where DIAM LT LU are correctly aligned ?

    "T1"  :  "BOULE"; DIAM :  "10"; LT :  "111"; LU :  "80"
    "T2"  :  "CYL";   DIAM :  "11"; LT :  "112"; LU :  "81"
    "T3"  :  "DROIT"; DIAM :  "12"; LT :  "113"; LU :  "82"
    "T4"  :  "CON";   DIAM :  "13"; LT :  "114"; LU :  "83"
    
    J 1 Reply Last reply 26 Nov 2019, 10:38
    0
    • V Offline
      V Offline
      VRonin
      wrote on 26 Nov 2019, 10:22 last edited by
      #2

      use \t instead of spaces

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      O 1 Reply Last reply 26 Nov 2019, 10:43
      3
      • O ODБOï
        26 Nov 2019, 09:52

        hi
        with this code

           qDebug()<< reMatch.captured(1)  << " : " << reMatch.captured(2)
                            << "; DIAM : " <<  reMatch.captured(3)
                            << "; LT : "  << reMatch.captured(4)
                            << "; LU : "  << reMatch.captured(5);
        

        the output is

        "T1"  :  "BOULE" ; DIAM :  "10" ; LT :  "111" ; LU :  "80"
        "T2"  :  "CYL" ; DIAM :  "11" ; LT :  "112" ; LU :  "81"
        "T3"  :  "DROIT" ; DIAM :  "12" ; LT :  "113" ; LU :  "82"
        "T4"  :  "CON" ; DIAM :  "13" ; LT :  "114" ; LU :  "83"
        

        how can i have an output where DIAM LT LU are correctly aligned ?

        "T1"  :  "BOULE"; DIAM :  "10"; LT :  "111"; LU :  "80"
        "T2"  :  "CYL";   DIAM :  "11"; LT :  "112"; LU :  "81"
        "T3"  :  "DROIT"; DIAM :  "12"; LT :  "113"; LU :  "82"
        "T4"  :  "CON";   DIAM :  "13"; LT :  "114"; LU :  "83"
        
        J Offline
        J Offline
        JonB
        wrote on 26 Nov 2019, 10:38 last edited by JonB
        #3

        @LeLev
        Is your output going to somewhere with a fixed-width font, else it's going to be problematic?

        Assuming it is, you can use @VRonin's \ts, or you pre-format the string with width specifiers (must be somewhere in QString) before passing to qDebug().

        1 Reply Last reply
        1
        • V VRonin
          26 Nov 2019, 10:22

          use \t instead of spaces

          O Offline
          O Offline
          ODБOï
          wrote on 26 Nov 2019, 10:43 last edited by
          #4

          @VRonin thank you very much

                  qDebug()<< reMatch.captured(1)
                              << ":"
                              << reMatch.captured(2) << "\t"
                              << "DIAM :"
                              <<  reMatch.captured(3)<<";"
                              << "LT :"
                              << reMatch.captured(4)<<";"
                              << "LU :"
                              << reMatch.captured(5)<<";";
          

          @JonB said in format stream output:

          width specifiers

          i will take a look at that also thank you!

          J 1 Reply Last reply 26 Nov 2019, 10:47
          0
          • O ODБOï
            26 Nov 2019, 10:43

            @VRonin thank you very much

                    qDebug()<< reMatch.captured(1)
                                << ":"
                                << reMatch.captured(2) << "\t"
                                << "DIAM :"
                                <<  reMatch.captured(3)<<";"
                                << "LT :"
                                << reMatch.captured(4)<<";"
                                << "LU :"
                                << reMatch.captured(5)<<";";
            

            @JonB said in format stream output:

            width specifiers

            i will take a look at that also thank you!

            J Offline
            J Offline
            JonB
            wrote on 26 Nov 2019, 10:47 last edited by JonB
            #5

            @LeLev
            https://doc.qt.io/qt-5/qstring.html#arg is the overload you want for strings, use fieldWidth argument (negative number if you want left-aligned as per your example). Tabs are quick and work till they don't (depends on number of characters determining where the next tab stop is).

            1 Reply Last reply
            1

            1/5

            26 Nov 2019, 09:52

            • Login

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