C++: Show Full Screen Images in a UI (Part I: Using Nokia Qt)

06 Jun

I was asked to develop a mini-application: just to show a single full screen image to hide some ugly console output. The application supports a command line: FullScreen.exe SomeImage. 






The first approach came to my mind is MFC, but it is not as easy as expected, and I come to hate MFC after I know Qt and other frameworks. Yes for sure, you can use SetWindowPos() etc. or other Windows APIs like that… But I would like to try some alternative solutions here.

I decided to try Qt first, and see how easy/difficult it is. I admit that I have no rich experience in Nokia Qt, but it turns out it is not as hard as imagined.





  • Delete the menuBar, mainToolbar and statusBar, as we do not need them.
  • Drag a label control to the form.


  • Change the label’s pixmap property and select an image from hard disk.
  • Tick the scaledContents checkBox.


Build (Ctrl + B) and Run (Ctrl + R), and the Qt program should like this:


Next, show this mainform in full screen mode. This can be easily done in main.cpp, by changing show() to showFullScreen():


Lastly, make the label stretch fit the canvas. Right click the canvas (inside the form, but outside the label image control), and select “Lay out” –> Lay Out in a Grid (Ctrl + G) to accomplish this.


It is almost done. But one can notice the margin between the lable/image and the frame


Select the centralWidget, set all the layout margin from “9” to “0”.


Build (Ctrl + B) and Run (Ctrl + R), and the full screen Qt program is done.

1 Comment

Posted by on June 6, 2012 in Programming


Tags: , , ,

One response to “C++: Show Full Screen Images in a UI (Part I: Using Nokia Qt)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: