Important: Please read the Qt Code of Conduct -

Adding a shadow to the MainWindow

  • hi,

    I have a MainWindow without the decoration (Frame) from the Window-Manager.
    Now i simply want to add a shadow behind the Window to make it appear more offset from the rest on the desktop.
    But I am not able to achive this. I found some hinds to this online but i can't get any of them to work.
    I am a Qt beginner so my knowledge is pretty limited.

    Any ideas on how to do this?
    Thanks in advance

  • Hi...


    I am not clear with your Requirements. Can u please be clear with it?

    Thanks & Regards

    1. Create a top level QWidget

    2. Make it translucent & frameless:

    3. Insert your MainWindow into that widget. Left some margins for shadow (5-15 px)

    4. Add QGraphicsDropShadowEffect to MainWindow:
      @QGraphicsDropShadowEffect *wndShadow = new QGraphicsDropShadowEffect;
      wndShadow->setColor(QColor(0, 0, 0, 160));

    ".zip with some examples":

  • thank you i will try this tomorrow now im going to bed.

    Just in case anyone is still wondering what i want to do:


    someting like the shadow or blur you can see around the window.

    edit2: i just checked out the examples and they are great. Thank you so much for that.
    I think i can do it now. If not, I will ask away again :)

    Thanks again

  • Hey guys,

    I managed to get what i wanted but without the Frame all the resizing, close, minimize and maximize is gone. So I implemented that but when I maximize it takes up the hole screen including the windows task bar.
    That is not quite how the maximize should work. It should maximize like any standard window.
    Any ideas on how to do this?

    Or, is it possible to style the window frame directly with qt? So i don't have to use the FramelessWindowHint.

    Thank you in advance

Log in to reply