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. Pop up Menu outside QtWindow
Forum Updated to NodeBB v4.3 + New Features

Pop up Menu outside QtWindow

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 174 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.
  • Q Offline
    Q Offline
    qthackerman
    wrote on last edited by
    #1

    Hi, for reasons that are immovable, I need to pop up a qt quick menu outside the QtQuickWindow.

    Qt doesn't allow this, and will try to reposition the menu inside the window if popped up outside.
    I was able to make it pop up where I wanted by first calling popup in 0,0 and then moving the contentItem and background to my desired location.
    However, the ClickedOutside area still believes the menu is at 0,0, so there is a patch in the top left corner that doesn't close the menu when pressed.

    import QtQuick 2.14
    import QtQuick.Controls 2.4 as CTL
    
    CTL.Menu {
        id: root
        function makeAppear(x, y) {
            popup(0, 0)
            contentItem.x = x
            contentItem.y = y
            background.x = x
            background.y = y
        }
        modal: true
        CTL.Overlay.modal: Rectangle {
            scale: 2
            color: "#55000000"
        }
    }
    

    I tried adding a mouseArea, hoping that that would appear in the pre-moved location, but I'm never able to get a print from it.

    property var hack: MouseArea {
            id: hack
            height: root.height
            width: root.width
            x: root.x
            y: root.y
            onClicked: console.log("clicked the thing")
        }
    

    Any suggestions?

    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