Be aware that any number in your source code that begins with a 0 is an octal literal. So 0123 is actually 01238, which is 8310.
To print with extra zeros, use the setfill() and setw() manipulators:
1 2 3 4 5 6
// Change the fill character from ' '.
// Remains changed until you change it to something else.
cout << setfill('0');
// Print a 1 with four leading zeros:
cout << setw(5) << 1 << "\n";
Hope this helps.
[edit]I keep forgetting to say: don't forget to #include <iomanip>
Then why did you use std::cout in the example you gave in your OP?
What kind of widget you are printing to in Qt can make a difference on how you handle this. Generally you are using a string, if you use QLineEdit or QLabel. In that case, just append the number to a string of 0s.