PDA

View Full Version : Centering layout in fullscreen application



Fuwex
21st November 2010, 21:02
Hi,

I'm fairly new to Qt, and I'm trying to make a sort of launcher application for my media center PC. Basically a fullscreen application which will let me choose a set of applications to launch (XBMC, Spotify, Firefox etc.).

Atleast to begin with, the application will consist of:
A background image filling up the entire screen A sort of "window"-looking rectangle which is going to act as a visual container A set of icons and labels, one icon and label for each application


For now I've subclassed a QLabel as my main widget, and I reckon I can simply paint the "window" onto the QLabel. What I'm struggling with right now, however, is how to approach the placement of the icons. Basically they need to be laid out in a grid (grid layout here, I suppose) in the middle of the screen, and expand as needed. The actual layout and expanding I reckon I should be able to accomplish, it's however the part where they're centered on the screen I'm having problems.

I can think of several solutions to this problem, however neither are ideal. In fact, far from it. What I need is a simple and effective way to center my grid layout, instead of having it lay out the entire screen/main widget. Essentially, I only want to layout a rectangular area in the center of the screen.

Hope I've made myself somewhat clear, and I hope someone can provide me with a simple way of accomplishing this :)

tbscope
22nd November 2010, 05:18
I personally would use a list view/widget with a custom delagate (if the painting needs to be different than the default painting)

If you use a grid layout, you can set margins and alligments.

What solutions have you thought about and why do you think they are not ideal?