johnyjj2
11th January 2011, 15:09
Hello!
I'd like to output vector to the qDebug in QT Creator. Unfortunately every number is in separated line. How can I avoid it?
If I execute similar code and output vector of vectors, the result looks as follows:
(1,2,3)
(2,4,6)
But if I do similar thing, i.e. only vector, I receive every number of the vector in separate line. I don't want qDebug to put characters of new line at the end of every execution. In order to avoid this, I have tried several different things but I haven't succeeded. I have either every number in separated line or build error (the third option is just no output in qDebug).
The code looks as follows:
//***** TESTING: SHOW DISTANCES AND WEIGHTS *****
//the version below works but everything is in separated line (with only zero digit in every of them)
QList<int>::iterator it2 = distances.begin();
qDebug() << "distances: " << *it2;
//the line below should do the same what the line above (without new line characters) but it does not work
//fprintf (stderr, "%s ", *it2);
//the line above was found here http://lists.trolltech.com/qt-interest/2005-11/thread00923-0.html
//the version below don't work; it was expected to write single line (0,0,0,...)
//QList< QList<int> >::iterator it2 = distances.begin();
//for( ; it2 != distances.end(); ++it2 )
// qDebug() << *it2 << " ";
//***********************************************
Regards!
I'd like to output vector to the qDebug in QT Creator. Unfortunately every number is in separated line. How can I avoid it?
If I execute similar code and output vector of vectors, the result looks as follows:
(1,2,3)
(2,4,6)
But if I do similar thing, i.e. only vector, I receive every number of the vector in separate line. I don't want qDebug to put characters of new line at the end of every execution. In order to avoid this, I have tried several different things but I haven't succeeded. I have either every number in separated line or build error (the third option is just no output in qDebug).
The code looks as follows:
//***** TESTING: SHOW DISTANCES AND WEIGHTS *****
//the version below works but everything is in separated line (with only zero digit in every of them)
QList<int>::iterator it2 = distances.begin();
qDebug() << "distances: " << *it2;
//the line below should do the same what the line above (without new line characters) but it does not work
//fprintf (stderr, "%s ", *it2);
//the line above was found here http://lists.trolltech.com/qt-interest/2005-11/thread00923-0.html
//the version below don't work; it was expected to write single line (0,0,0,...)
//QList< QList<int> >::iterator it2 = distances.begin();
//for( ; it2 != distances.end(); ++it2 )
// qDebug() << *it2 << " ";
//***********************************************
Regards!