PDA

View Full Version : Styling border for QGroupBox



Paluth
8th February 2012, 14:44
Hi all,

I'm trying to style the borders of a QGroupBox with an image.

This is the code I got on the top level widget stylesheet:

QWidget {
background-image:url(:/background/stainedpaper7.jpg) repeat;
background-position: top left;
}

QGroupBox {
margin:20px;
border-image : url(:/border/wm-corner.png);
border-left: 80px;
border-top: 80px;
border-right: 80px;
border-bottom: 80px;
}

QGroupBox::title {
subcontrol-origin: border;
subcontrol-position: top center; /* position at the top center */
padding: 0 3px;
}

There are many problems here.
1 - The first is that the content area is reduced by the border. Sure this is expected in most cases but in my case I would prefer for the content area to invade some of the border space if possible. The reason for this is clear in the attached image. There is much more room for content than is actually used.
2 - The margin in the GroupBox is not transparent. The parent background is not visible in that area.
3 - The border is not transparent, again the parent background is not visible.

In the preview I see what I actually wanted (except for 1). Take a look (left running app, right preview in Qt Creator):
7380

I'm using transparent png images for the border. Runing Qt 4.8 and Qt Creator 2.4 on Windows 7 32bit, targeting Windows Desktop.

Can anyone help me?