Changing the window title
Hey.
Basically im trying to update the window title for my program.
At the moment im using setWindowTitle to do this, but I can't figure out how to include an int variable to display properly.
I have an integer for 'lives' and setting the title to something like "setWindowTitle("Lives: " + lives); produces strange errors.
Anyone able to help?
Re: Changing the window title
You can't add an integer to a string in C++ (assuming you don't overload operator+ for that purpose). Use stringstreams:
Code:
#include <sstream>
// ...
std::ostringstream oss;
oss << "Lives: " << lives;
setWindowTitle(oss.str().c_str()); // Assuming setWindowTitle takes a C-style string
Re: Changing the window title
Thanks heaps, that really helped