[Qt-interest] QDialog with rounded "corners"
Gabriel M. Beddingfield
gabrbedd at gmail.com
Fri Feb 11 05:14:33 CET 2011
On Thursday, February 10, 2011 08:08:00 am Markus Franke
wrote:
> I am having problems when styling QDialog in my Qt
> application. Basically I would like to have dialog
> windows which have rounded corners. I have a class
[snip]
>
> The result which I achieve are actually quiet similar to
> what I want. I see rounded "corners" but it seems like
> the background is not taken into account as I can see a
> few pixels of the background color in each of the
> corners. (see attached dialog.png)
I did pretty much the same thing with StretchPlayer:
http://www.teuton.org/~gabriel/stretchplayer/
See src/PlayerWidget.cpp (and src/PlayerWidget.hpp). The
trick, in a nutshell, is:
1. You gotta have a compositing window manager.
(Most modern distros have them by default now)
2. Set the WA_TranslucentBackground attribute.
3. Create a mask for the rounded corners, and
set it up in the paintEvent().
4. I don't remember if it's required to derive from
a QMainWindow or not.
BTW, doing this (esp. the mask) requires more CPU... which
was kind of a pain in my app.
-gabriel
More information about the Qt-interest-old
mailing list