[PySide] how to suppress qwidget's drop shadow under windows?

Frank Rueter | OHUfx frank at ohufx.com
Sat Jul 12 05:19:47 CEST 2014


brilliant, that was precisely what I was just trying to do. Thanks 
heaps, you just saved me an hour of research and testing. I assumed 
there was going to be an event handler I could simply re-implement to 
get this behaviour, so would have looked in the wrong direction.

Cheers!
frank

On 12/07/14 1:13 PM, Tony Barbieri wrote:
> Yea, that is one downside.  We worked around it by doing the following:
>
> |class  ClosePopupFilter(QtCore.QObject):
>
>      def  eventFilter(self, target, event):
>          if  event.type() == QtCore.QEvent.WindowDeactivate:
>              target.close()
>          return  False
>
> class  Popup(QtGui.QWidget):
>
>      def  __init__(self, parent=None):
>          super(Popup, self).__init__(parent)
>
>          self.__popup_filter = ClosePopupFilter()
>          self.installEventFilter(self.__popup_filter)
>
>
>          self.setWindowFlags(QtCore.Qt.FramelessWindowHint |
>                                   QtCore.Qt.WindowStaysOnTopHint |
>                                   QtCore.Qt.CustomizeWindowHint |
>                                   QtCore.Qt.Tool)
> |
>>
>
> On Fri, Jul 11, 2014 at 10:51 PM, Frank Rueter | OHUfx 
> <frank at ohufx.com <mailto:frank at ohufx.com>> wrote:
>
>     Ah, thanks.
>     one issue I see the Qt.Tool flag is that it won't close the widget
>     when I click outside of it, something the Qt.Popup flag does for me.
>
>     But I guess I can re-implement one of the event handles to
>     reproduce this behaviour. MIght be easier than hunting down
>     whatever would suppress the shadow in the default palette.
>
>     Cheers,
>     frank
>
>
>     On 12/07/14 12:28 PM, Tony Barbieri wrote:
>>     Hey Frank,
>>
>>     Checkout this page: http://qt-project.org/doc/qt-4.8/qt.html
>>
>>     Here is the description for those two flags:
>>
>>     Qt::Popup 	0x00000008 | Window 	Indicates that the widget is a
>>     pop-up top-level window, i.e. that it is modal, but has a window
>>     system frame appropriate for pop-up menus.
>>     Qt::Tool 	0x0000000a | Window 	Indicates that the widget is a
>>     tool window. A tool window is often a small window with a smaller
>>     than usual title bar and decoration, typically used for
>>     collections of tool buttons. If there is a parent, the tool
>>     window will always be kept on top of it. If there isn't a parent,
>>     you may consider using Qt::WindowStaysOnTopHint as well. If the
>>     window system supports it, a tool window can be decorated with a
>>     somewhat lighter frame. It can also be combined with
>>     Qt::FramelessWindowHint.
>>
>>     Glad it helped!
>>
>>     Best,
>>
>>
>>
>>     On Fri, Jul 11, 2014 at 9:54 PM, Frank Rueter | OHUfx
>>     <frank at ohufx.com <mailto:frank at ohufx.com>> wrote:
>>
>>         Great, that did in deed fix it, thanks so much!!
>>         Can somebody explain what those two flags actually try to do?
>>         I'm still finding it difficult to find comprehensive
>>         documentation about flags in general.
>>
>>
>>         Cheers,
>>         frank
>>
>>         On 11/07/14 11:23 PM, Tony Barbieri wrote:
>>>         Hey Frank,
>>>
>>>         I'm pretty sure we use the QtCore.Qt.Tool flag rather than
>>>         the QtCore.Qt.Popup flag to deal with removing the shadow.
>>>          If that doesn't work I can look deeper into how we've dealt
>>>         with this.
>>>
>>>         Best,
>>>
>>>
>>>         On Thu, Jul 10, 2014 at 11:15 PM, Frank Rueter | OHUfx
>>>         <frank at ohufx.com <mailto:frank at ohufx.com>> wrote:
>>>
>>>             Hi all,
>>>
>>>             I was given some code that uses a QWidget, makes it
>>>             completely
>>>             transparent, then adds a custom paintEvent to draw some
>>>             custom items.
>>>             This is meant or a fancy right click menu. Under OSX it
>>>             ll looks swell,
>>>             but under windows I get the default drop shadow, because
>>>             of the
>>>             QtCore.Qt.Popup flag.
>>>             e.g.:
>>>             class MyMenu(PySide.QtGui.QWidget):
>>>
>>>                def __init__(self):
>>>              QtGui.QWidget.__init__(self)
>>>              self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
>>>              self.setWindowFlags(QtCore.Qt.Popup |
>>>             QtCore.Qt.FramelessWindowHint)
>>>
>>>             w = MyMenu()
>>>             w = show()
>>>
>>>             What is the easiest way to turn off that off (drop
>>>             shadows for
>>>             transparent widgets just look irritating :-D )? I guess
>>>             I could inherit
>>>             from QMenu instead of QWidget but would expect more work
>>>             to get it to
>>>             it's current state and am not entirely sure if that
>>>             would fix the issue.
>>>
>>>             Any ideas?
>>>
>>>             Cheers,
>>>             frank
>>>
>>>
>>>
>>>
>>>
>>>             _______________________________________________
>>>             PySide mailing list
>>>             PySide at qt-project.org <mailto:PySide at qt-project.org>
>>>             http://lists.qt-project.org/mailman/listinfo/pyside
>>>
>>>
>>>
>>>
>>>         -- 
>>>         Tony
>>
>>
>>
>>
>>     -- 
>>     Tony
>
>
>
>
> -- 
> Tony

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20140712/a810baa7/attachment.html>


More information about the PySide mailing list