Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding a shadow to the MainWindow
Forum Updated to NodeBB v4.3 + New Features

Adding a shadow to the MainWindow

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 10.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    armmie
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Macro
      wrote on last edited by
      #2

      Hi...

      Sorry..!!!

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

      Thanks & Regards

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mtrch
        wrote on last edited by
        #3
        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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          armmie
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            armmie
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved