In Qt creator you are supposed to create a project, which has one cpp file containing the main function. It is not meant to compile single files (though you can by creating a project and copying the code in the main file of the project.
For you I would recommend using gcc from terminal. Open the terminal in the directory containing the file and type:
g++ filename.cpp
You can also use Geany (A simple but very nice IDE where you don't need to create a project. Open the file and compile it with a click.