[Interest] Semi transparent background for contextual menu
Nicolas Krieger
nicolas.krieger-medecom29 at orange.fr
Mon Mar 20 11:21:14 CET 2017
You're right. I think having a semi-opaque contextual menu is feasible,
but the management has to be done by the application and no more by Qt.
Thank's for your answers
Nicolas
Le 17/03/2017 à 20:03, Etienne Sandré-Chardonnal a écrit :
> Child widget transparency is rendered by Qt styles directly. On the
> other hand, on a top level window, transparency must be handled by the
> system. This is completely different.
>
> It is actually possible but more complicated to make transparent
> windows, look for WA_TranslucentBackground.
>
> Cheers,
>
> Etienne
>
> 2017-03-17 9:59 GMT+01:00 Nicolas Krieger
> <nicolas.krieger-medecom29 at orange.fr
> <mailto:nicolas.krieger-medecom29 at orange.fr>>:
>
> Hi,
>
> Thank you for the answer. I made it work with your help, but I
> lost the transparency of the popup.
>
> If the widget has a parent, there is transparency, but I lost the
> Qt::ActiveWindowFocusReason when I lost focus
>
> Le 16/03/2017 à 22:38, Etienne Sandré-Chardonnal a écrit :
>> I forgot, in order to detect when the window lost "focus" (ie is
>> no longer the active window), you need to catch QFocusEvent, and
>> check if reason() is Qt::ActiveWindowFocusReason
>>
>> Cheers,
>>
>> Etienne
>>
>> 2017-03-16 22:34 GMT+01:00 Etienne Sandré-Chardonnal
>> <etienne.sandre at m4x.org <mailto:etienne.sandre at m4x.org>>:
>>
>> Hi,
>>
>> That's because a context menu is a system level window, not a
>> widget.
>> And what you call focus is in fact not focus, but active
>> window. See QApplication::activeWindow
>>
>> You create such a window by creating a QWidget with no parent
>> and a WindowFlag:
>>
>> QWidget(0, Qt::Popup);
>>
>> 2017-03-16 15:56 GMT+01:00 Nicolas Krieger
>> <nicolas.krieger-medecom29 at orange.fr
>> <mailto:nicolas.krieger-medecom29 at orange.fr>>:
>>
>> Hi,
>>
>> I try to have a contextual menu with a semi-transparent
>> background. I didnt manage to to it with QMenu, so I
>> decided to use a custom widget.
>>
>> I have no problem to have a widget with a
>> semi-transparent background, I just changed the alpha of
>> the background color.
>>
>> My problem is that I want this widget to behave like a
>> contextual menu, that is to say, I want it to be closed
>> when focus is lost. But this is lot as soon as I clic on
>> a children-widget of this menu. I don't know how to do.
>>
>> Nicolas Krieger
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest
>> <http://lists.qt-project.org/mailman/listinfo/interest>
>>
>>
>>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org <mailto:Interest at qt-project.org>
> http://lists.qt-project.org/mailman/listinfo/interest
> <http://lists.qt-project.org/mailman/listinfo/interest>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170320/d51ad969/attachment.html>
More information about the Interest
mailing list