OS X transparent panels in Qt?

拜拜、爱过 提交于 2019-12-14 04:27:18

问题


Is there a way to create a transparent panel as described by the Apple Human Interface Guidelines in Qt 4.6 (built for OS X 10.6/Cocoa)?

If not, are there any alternatives similar in look and function?

I understand that Qt is a cross platform toolkit, but I want my application to feel as "native" as possible.


回答1:


I haven't tried on Mac, but this should be possible. Here's what the QWidget docs say:

Creating Translucent Windows

Since Qt 4.5, it has been possible to create windows with translucent regions on window systems that support compositing.

To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground attribute with setAttribute() and ensure that its background is painted with non-opaque colors in the regions you want to be partially transparent.

Platform notes:

X11: This feature relies on the use of an X server that supports ARGB visuals and a compositing window manager.

Windows: The widget needs to have the Qt::FramelessWindowHint window flag set for the translucency to work.

I imagine your panel is a top-level widget, so make sure to set Qt::WA_TranslucentBackground as directed in the above.



来源:https://stackoverflow.com/questions/3568457/os-x-transparent-panels-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!