format stream output
-
hi
with this codeqDebug()<< 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" -
hi
with this codeqDebug()<< 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"@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 inQString) before passing toqDebug(). -
@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!
-
@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!
@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).