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. Changing the drop drop shadow of a QMenu
QtWS25 Last Chance

Changing the drop drop shadow of a QMenu

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.4k Views
  • 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.
  • V Offline
    V Offline
    VogelPapaFinn
    wrote on last edited by
    #1

    Hey guys.

    How do I change the drop shadow of a QMenu? Using setGraphicsEffect() with a QGraphicsDropShadowEffect does not work. Im using QTWidgets with C++.
    The default shadow is pretty bad and only at the bottom and right corner.

    Thanks.

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

      Maybe you have to set Qt::NoDropShadowWindowHint window flag for your QMenu.

      [edit] shadow effet only works inside the widget, look at my example here:
      https://forum.qt.io/post/688750

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VogelPapaFinn
        wrote on last edited by VogelPapaFinn
        #3

        This only removes the default drop shadow.

        // EDIT:
        What do you mean with "inside the widget"?

        M 1 Reply Last reply
        0
        • V VogelPapaFinn

          This only removes the default drop shadow.

          // EDIT:
          What do you mean with "inside the widget"?

          M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          @VogelPapaFinn
          Shadows can't be drawn outside the top level widget frame.
          In your case QMenu.

          V 1 Reply Last reply
          0
          • M mpergand

            @VogelPapaFinn
            Shadows can't be drawn outside the top level widget frame.
            In your case QMenu.

            V Offline
            V Offline
            VogelPapaFinn
            wrote on last edited by
            #5

            @mpergand dafuq. Then how does it create the default shadow??

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by Chris Kawa
              #6

              A menu is a window. Windows have a client and non-client area. Client area is everything inside the frame. That's where the application does its own painting, either through Qt or other means. QGraphicsEffect is just a helper that lets you draw stuff, but it is limited to the client area.

              The non-client area is the frame and everything outside of it (e.g. the shadow). That part is painted by the OS and its window manager, which are platform specific and can vary widely between OS versions or window managers. Some may draw shadows, some may draw colored borders, some may have none of it. It's mostly out of control of the app what the style of that area is. Some window managers expose some customization points, like that NoDropShadowWindowHint that @mpergand mentioned, but that's why it has "hint" in the name - it's a suggestion to the OS and it's up to it to honor it or not. There's no direct control over how the window manager draws window frames or what effects it adds to it. It will look differently on different systems.

              V 1 Reply Last reply
              3
              • Chris KawaC Chris Kawa

                A menu is a window. Windows have a client and non-client area. Client area is everything inside the frame. That's where the application does its own painting, either through Qt or other means. QGraphicsEffect is just a helper that lets you draw stuff, but it is limited to the client area.

                The non-client area is the frame and everything outside of it (e.g. the shadow). That part is painted by the OS and its window manager, which are platform specific and can vary widely between OS versions or window managers. Some may draw shadows, some may draw colored borders, some may have none of it. It's mostly out of control of the app what the style of that area is. Some window managers expose some customization points, like that NoDropShadowWindowHint that @mpergand mentioned, but that's why it has "hint" in the name - it's a suggestion to the OS and it's up to it to honor it or not. There's no direct control over how the window manager draws window frames or what effects it adds to it. It will look differently on different systems.

                V Offline
                V Offline
                VogelPapaFinn
                wrote on last edited by
                #7

                @Chris-Kawa so there is no chance of using a good shadow? Oh man that shit sucks.

                Chris KawaC 1 Reply Last reply
                0
                • V VogelPapaFinn

                  @Chris-Kawa so there is no chance of using a good shadow? Oh man that shit sucks.

                  Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @VogelPapaFinn You can try to override the non-client area painting if your particular platform lets you. You would override nativeEvent() and look for the platform specific message to implement the painting. For example on Windows that's the WM_NCPAINT message.
                  But this is highly platform and window manager specific. You're on your own there. Qt can't help you with this, so no QPainter, QGraphicsEffect or anything like that. Only native APIs.

                  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