Qt-interest Archive, February 2007
Semi- transparent QWidget
Message 1 in thread
Hi,
I need to make a semi transparent widget / alpha around 30/ with parent
contest of which should be visible with alpha. Can somebody give me any
source / example of something like this.
I know that 4.2 introduce even more functionalities as setOpaque
, Qt::WA_ContentsPropagated etc. but I can't not make them work.Please help
Cheers,
Julian
--
[ signature omitted ]
Message 2 in thread
Check the "analogclock" example that comes with Qt.
You can stick this into any widget, and will have the parent contents
shine through (semi transparently through the hands, otherwise fully
opaque).
The trick is - that there is no trick :) Just paint your child widget with
a brush or pen that is not fully opaque.
Volker
"Julian Michailov" <julian.m@xxxxxxxxxx> wrote in message
news:ertvrv$t6m$1@xxxxxxxxxxxxxxxxxxxxx
> Hi,
>
>
>
> I need to make a semi transparent widget / alpha around 30/ with parent
> contest of which should be visible with alpha. Can somebody give me any
> source / example of something like this.
>
> I know that 4.2 introduce even more functionalities as
> setOpaque , Qt::WA_ContentsPropagated etc. but I can't not make them
> work.Please help
>
>
>
> Cheers,
>
>
>
> Julian
>
>
--
[ signature omitted ]
Message 3 in thread
Thanks Volker,
I succeed to make it. It works perfect.
My problem was / and still it is/ that I can not draw semi transparent
rectangles over Qwiget which / here is the key moment/ playing Video . What
I do is adding the MPlayer into a Widget and want to add semi transparent
description as " What is this in Qt -Demo".
I succeed to make a fully transparent QImage and to draw with QPainter over
it and everything works fine. The problem is when I draw a semi transparent
thing it comes as fully opaque. That is situation only over MPlayer running
into Widget otherwise works perfectly.
Do you have any idea how I can make it?
Cheers,
Julian
"Volker Hilsheimer" <unwatched@xxxxxxx> wrote in message
news:erv4k4$a4$1@xxxxxxxxxxxxxxxxxxxxx
> Check the "analogclock" example that comes with Qt.
>
> You can stick this into any widget, and will have the parent contents
> shine through (semi transparently through the hands, otherwise fully
> opaque).
>
> The trick is - that there is no trick :) Just paint your child widget with
> a brush or pen that is not fully opaque.
>
> Volker
>
>
> "Julian Michailov" <julian.m@xxxxxxxxxx> wrote in message
> news:ertvrv$t6m$1@xxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>>
>>
>> I need to make a semi transparent widget / alpha around 30/ with parent
>> contest of which should be visible with alpha. Can somebody give me any
>> source / example of something like this.
>>
>> I know that 4.2 introduce even more functionalities as
>> setOpaque , Qt::WA_ContentsPropagated etc. but I can't not make them
>> work.Please help
>>
>>
>>
>> Cheers,
>>
>>
>>
>> Julian
>>
>>
>
>
--
[ signature omitted ]
Message 4 in thread
> I succeed to make it. It works perfect.
>
> My problem was / and still it is/ that I can not draw semi transparent
> rectangles over Qwiget which / here is the key moment/ playing Video .
> What I do is adding the MPlayer into a Widget and want to add semi
> transparent description as " What is this in Qt -Demo".
>
> I succeed to make a fully transparent QImage and to draw with QPainter
> over it and everything works fine. The problem is when I draw a semi
> transparent thing it comes as fully opaque. That is situation only over
> MPlayer running into Widget otherwise works perfectly.
>
> Do you have any idea how I can make it?
Qt's support for semi transparent widget really is a feature of Qt; it's
not a feature of the windowing system that Qt just happened to start using
in version 4.2.
For this to work, all widgets in the widget hierarchy have to cooperate.
I.e. all of them have to paint themselves into Qt's "backingstore", so
that Qt can correctly compose the look of the complete window. Any widget
that does not render into the backingstore will not, and cannot, shine
through other widgets that are on top, or of widgets below shine through.
This means that any QWidget that has the PaintOnScreen flag set (i.e.
QGLWidget), and any window that is not a Qt widget, cannot participate in
the semi-transparency of Qt, unless you jump through several hopps to make
it work. I.e. you could just not show the MPlayer at all, but instead have
it provide the frames that you then paint into the QWidget using a
paintEvent implementation. However, this is naturally going to be very
slow and very heavy on the CPU (and I don't know enough about MPlayer to
say if you can do this in the first place).
Alternatively, you can use toplevel widgets and modify their opacity. Qt
doesn't know what is "behind" a toplevel windows - only the windowing
system knows. So the windowing system, if it supports the notion of semi
transparent toplevel windows, can take care of the composition. But this
might again fail (or at least cause drastic performance decrease) in some
cases, i.e. your OpenGL rendering might start to go through the windowing
system rather than directly blt to the framebuffer.
Volker
--
[ signature omitted ]