I just want to make you aware of on option to store such information user names and related information into a file. "QSettings ":http://doc.qt.nokia.com/4.7/qsettings.html Typically QSettins facilitates that quite nicely for different applications and platforms. On windows you have the option to store in ini-files and also for linux the data are more easily maintained compared to hand-knitted files. You may use the file structure behind the scenes and open it from any place in your program. Maybe that would be of help.
I cannot answer your quite detailed question above. main.cpp is just a name of a file which presumably holds most or all information of your code. It all depends on what you are trying to achieve and how your program is setup. I guess it is somehow possible, but there is no way to provide details without knowing more. Anyhow, I think it would be good if you have a look to the possibilities of QSettings.