|
-
April 27th, 2008, 10:32 AM
#1
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?
-
April 27th, 2008, 11:08 AM
#2
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
- Alon
-
April 27th, 2008, 11:17 AM
#3
Re: Changing the window title
Thanks heaps, that really helped
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|