[Interest] Widget contents draw over rounded borders

Hamish Moffatt hamish at risingsoftware.com
Wed Oct 1 02:38:05 CEST 2014


I'm trying to put rounded borders on some widgets (QFrame, QGroupBox, 
QListView for example) using border-radius in the stylesheet, but I find 
that the widget contents tend to draw over the borders.

tl;dr; is there a way to have the borders drawn later, over the top of 
the contents?


With the following stylesheet, the borders of a QListWidget are drawn 
over by the items in it. I could set the background-color of those items 
to transparent but that doesn't help with the selected item, for which I 
want to set a background color.



#Form { background-color: white; }


QListWidget { border-radius: 6px; border: 1px solid red; }

QListWidget::item:selected { background-color: lightblue; }



Now if I want to put rounded borders on a QGroupBox, the title text ends 
up in the wrong place (on Windows anyway). And if I fix that by adding 
padding and margin, the border is still obliterated because the title 
text draws its background over the top.




#Group1 { border-radius: 6px; border: 1px solid red; }

#Group2 { border-radius: 6px; border: 1px solid red; margin-top: 10px; }

#Group2::title { padding-top: -10px; padding-left: 10px; }


And if you make QGroupBox::title's background transparent, the border 
line goes right through it...


Suggestions most welcome.


Thanks

Hamish

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141001/948b5da2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frame-border1.PNG
Type: image/png
Size: 1655 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141001/948b5da2/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frame-border2.PNG
Type: image/png
Size: 1340 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141001/948b5da2/attachment-0001.png>


More information about the Interest mailing list