PDA

View Full Version : background transparency



hma
4th April 2007, 02:13
hi

I'm trying to do an Autodesk Sketcbook style pie-menu, where icons hover around a center point without a donut/circle shaped background and selection is marked by a line drawn from center of the pie to cursor position.
So far, I have everything working, except getting completely rid of the the background. Masking out everything except the icons solves most of the problem, but then I can't draw the line from center to cursor position.
I have tried setting widget's background color role to point to a transparent color, and setting Qt::WA_NoSystemBackground attribute , but no luck. From one source I understood that transparency does not work on all GUI styles, so I tried chancing that, but that didn't work.

Do you have any hints how to solve this? I'm using Qt 4.2 (could chance to 4.3 if that helps) on WindowsXP.

marcel
4th April 2007, 06:04
Hello,

One idea is to paint yourself the entire widget ( overwrite paintEvent() ). For the parts that you want to be transparent you can set the painter opacity to something very small (whatever suites you ).

You should use setOpacity just to obtain transparency. For the pie shape you should set the painter clip path to a circle( clip everything outside ).

No time for an example now... Read in the Assistant the QPainter class reference. It should provide enough info.

Marcel

wysota
4th April 2007, 08:22
Maybe you should draw the menu (and the line) on a pixmap/image first and use createHeuristicMask() to create a mask which you'll then be able to apply on the widget.