Please edit your post to use [code] [/code] tags. It is hard to read.

The first function has precisely nothing to do with Qt. It's C++, Qt imposes no restrictions on your use of C++.

We cannot tell you if n is correct or not, but it would depend on what the getline() function is (it does not seem to be the fstream or stringstream member function).

The second function creates a graphics scene, containing n pixmap items, and a view (both likely to be memory leaks) . "container" is unused. "icon2" is unused. You ask for the item "image2" at (0,180) only to try to add it the the scene again.