I am trying to use Qt logging, in the frame of which I am looking for the equivalent of setw() and setfill(). I do have the code
int TestNum = 12;
ostringstream oss;
oss << setw(5) << setfill(' ') << TestNum;
qInfo() << "Simple ='" << TestNum << "'";
qInfo() << "Stream ='" << oss.str().c_str() << "'";
qInfo() << "QString ='" << QString("%1").arg(TestNum,5) << "'";
qInfo() << "char* ='" << QString("%1").arg(TestNum,5).toStdString().c_str() << "'";
the output of which is
Simple =' 12 '
Stream =' 12 '
QString =' " 12" '
char* =' 12 '
My questions:
With all examples: how can I rid off of the obsolete ' ' around my payload part? (if I want to write 12 in hexa, I receive ' x C ')
The quotation marks are part of the string? (according to the conversions, not. Within the frames of QT, yes.) How much the conversion is valid, if the printed image, the length, etc. differs?
Am I right that in the frames of Qt, without converting the results of the function, producing the number padded with the requested number of spaces, cannot be produced?
Why '<<' is not overloaded for 'setw()'? Why in general the standard C++ types like std::string are not supported in a C++ framework? (I do need to convert to C-s char*)
For compatibility with C++ (like functions which can be used with and without Qt), the ostringstream methods seems to produce the less items. Any better idea?