Lets say we have a variable called X
and we do some operations on it. now for printing it on the QtextEdit
I want to print it like this cout
on console:
cout << "The value of X is " << X << endl;
But the setText
function only prints out a QString
not both "the value of ... " and X
.
You can use a QTextStream
to write data into a QString
similar to cout
:
int X = 42;
QString str;
QTextStream out(&str);
out << "The value of X is " << X << endl;
qDebug() << str;
Output:
"The value of X is 42
"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments