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.