[Qt-interest] How to disable window shadow on Mac?

Dmitry Savenko dsavenko at gmail.com
Mon Aug 30 08:02:08 CEST 2010


Hello!

Thanks for your answer, but the things appeared to be more
complicated. I tried different flags (including
Qt::FramelessWindowHint), I tried inheriting from QSplashScreen.
Nothing helped, the shadow is always there. It seems it can't be done
by using QT only. The only way I found is to use native Mac OS calls
(Carbon framework). In case someone is interested in that, I'll
describe it here. Actually, I'm a newbie to native Mac OS programming,
so my solution may not be fully correct, but it worked for me.

Firstly, one should add the following line to .pro file:
     macx:LIBS += -framework Carbon
After that, you can use the following code snippet to disable the
shadow of a window.

#ifdef Q_WS_MAC
    #include <MacWindows.h>
#endif
// .....................
void disableShadow(QWidget* window) {
#ifdef Q_WS_MAC
    HIViewRef view = (HIViewRef)window->winId();
    WindowRef window = HIViewGetWindow(view);
    ChangeWindowAttributes(window, kWindowNoShadowAttribute,
kWindowNoAttributes);
#endif
}

Best regards,
Dmitry.

On Fri, Aug 27, 2010 at 10:00 PM,  <Oliver.Knoll at comit.ch> wrote:
> On 2010-08-27 Dmitry Dmitry Savenko wrote:
>
>> shadow. Is it possible to disable the shadow?
>
> I guess you can control that with one of these flags:
>
>  http://doc.trolltech.com/4.6/qt.html#WindowType-enum
>  http://doc.trolltech.com/4.6/widgets-windowflags.html
>
> If I would have to guess I would say it would be Qt::FramelessWindowHint what you are looking for. Btw are you implementing your own splashscreen,, or are you using http://doc.trolltech.com/4.6/qsplashscreen.html? Because in the later case I would expect that it is drawn without shadow already (ie the proper window flags are already set) - but I have never tried it so far (even though I got a Mac since several months, too ;)
>
> Cheers, Oliver
> --
> Oliver Knoll
> Dipl. Informatik-Ing. ETH
> COMIT AG - ++41 79 520 95 22
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list