Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Popup QML Window with Transparent background, changed 5.14->5.15->6.2
Forum Updated to NodeBB v4.3 + New Features

Popup QML Window with Transparent background, changed 5.14->5.15->6.2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.1k 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.
  • A Offline
    A Offline
    antiocles
    wrote on last edited by
    #1

    Hello,

    I have a cross platform application that has a menu popup that can be triggered by hardware at any cursor position with the cursor centered in the popup. This custom menu is not rectangular but circular, and the window itself was transparent. When the user mouses out of the menu, it will close.

    In qt 5.14 and prior, everything worked as expected with a transparent window behind the central "menu" 5.14

    In 5.15, on mac the transparency seems impossible to regain no matter what combination of flags and settings or workarounds I apply, and always is black. 5_15

    In 6.2, the behavior seems to have changed again. Now there is a window shadow and no longer possible to hide the window frame. 6_2

    This is the exact same code, simply compiled using 5.14, 5.15, and latest 6.2 on Mac. Here is a small application demonstrating the behavior.

    Any thoughts? Any better way to get a transparent window containing a custom drawn QML interface of non-rectangular shape? Windows seems to retain the behavior through all revisions so maybe this is a Mac only bug?

    import QtQuick 2.14
    import QtQuick.Window 2.14
    import QtQuick.Controls 2.14
    
    Window {
        width: 480
        height: 600
        visible: true
        Button {
            anchors.centerIn: parent
            text: "Open"
            onClicked: popup.show()
        }
    
        //oversized transparent popup window that will appear on top of other windows/applications when main is minimized
        Window {
            id: popup
            width: 100 * 3.0 //oversized so we get messages on leaving our mouse area... else mouse exits and no "exit" signal
            height: 100 * 3.0 //oversized so we get messages on leaving our mouse area... else mouse exits and no "exit" signal
            flags: Qt.Window | Qt.FramelessWindowHint | Qt.WA_TranslucentBackground | Qt.WindowStaysOnTopHint
            transientParent: null
            color: "transparent" //"#00000001" // fully trensparent does not seem to work on some earlier qt verions, since resolved!
    
            Rectangle {
    
                anchors.centerIn: parent
                width: 100
                height: 100
                color: "blue"
                radius: 10
                Text {
                    anchors.centerIn: parent
                    text: "Popup"
                }
                MouseArea {
                    anchors.fill: parent
                    hoverEnabled: true
    
                    onContainsMouseChanged: {
                        if(!containsMouse) {
                            popup.hide(); //button contains it...
                        }
                    }
                }
            }
        }
    }
    
    
    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Have you tried the Qt.NoDropShadowWindowHint flag?

      A 1 Reply Last reply
      0
      • GrecKoG GrecKo

        Have you tried the Qt.NoDropShadowWindowHint flag?

        A Offline
        A Offline
        antiocles
        wrote on last edited by antiocles
        #3

        @GrecKo said in Popup QML Window with Transparent background, changed 5.14->5.15->6.2:

        Qt.NoDropShadowWindowHint

        Thank you,

        This will remove the drop shadow on 6.2 (yay), but the transparency that worked prior in 5.14 and all previous is gone in 5.15 and later. It is like the alpha blending is silently ignored or something else overrides it. Also, was not needed prior in 5,14 and earlier and seems different then win desktop behavior.

        1 Reply Last reply
        0
        • GrecKoG Offline
          GrecKoG Offline
          GrecKo
          Qt Champions 2018
          wrote on last edited by
          #4

          I guess the way forward is to report it as a bug (which it seems it is) and hope for a fix or a workaround.

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

            @antiocles @GrecKo Did you able to fix this issue on macOS?
            As mentioned earlier this issue is only on macOS.

            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