Transparent QT tool over viewport?

63 views
Skip to first unread message

maks

unread,
May 8, 2020, 3:40:06 AM5/8/20
to Python Programming for Autodesk Maya
Hi,
I am trying to write a tool with a GUI similar to that: https://youtu.be/ggQ8_IoDgl4?t=11
I.e. making semi-transparent buttons around current mouse position.

It seems that WA_TranslucentBackground doesn't work over viewport. I get black fill where the tool's window overlaps with the viewport (works over other GUI though.)

Some googling gave me that: 
https://knowledge.autodesk.com/support/maya/learn-explore/caas/sfdcarticles/sfdcarticles/How-Maya-handles-transparent-Qt-widget.html

It seems that transparency over view-port is not supported? Like at all?

I would appreciate any pointers of how could one go about writing a tool like that.

Thanks!

luceric

unread,
May 17, 2020, 9:15:28 PM5/17/20
to Python Programming for Autodesk Maya
Hi.
As written in the autodesk.com post, the way you write a UI like this is to create a transparent floating window, one without borders and title bar, positioned on top of the viewport.  Then, it's the OS doing the alpha compositing, and everything works.  This is how the hotbox and marking menus are implemented.

What is not working is creating a qt widget that is a transparent child of the viewport, for the technical reasons stated in that article.  While that may seem like an issue, it's actually not what you would really want.  You usually do not want to have a menu-like widget to be clipped by the viewport rectangle if the mouse was near the borders.  You want that menu to appear around the mouse position, even if some of it would appear on top, for example, of the Attribute Editor, and you also want to get the mouse messages even when the mouse is not inside the viewport. The only way to do all of that that is to make it a separate always-on-top floating window.  It will also redraw faster.
Reply all
Reply to author
Forward
0 new messages