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...

    Sorry..!!!

    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:
      @setWindowFlags(Qt::FramelessWindowHint);
      setAttribute(Qt::WA_TranslucentBackground);@

    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->setBlurRadius(9.0);
      wndShadow->setColor(QColor(0, 0, 0, 160));
      wndShadow->setOffset(4.0);
      mainWindow->setGraphicsEffect(wndShadow);@

    ".zip with some examples":https://docs.google.com/file/d/0Bzw1xBVt0mokd0tvQkVkUzRfcnc/edit?usp=sharing



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

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

    !http://www.ubuntu.com/static/u/img/ubuntu/screenshot-whats-new-web-apps-906x509.png(Screenshot)!

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.