Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Pop up Menu outside QtWindow

    QML and Qt Quick
    1
    1
    79
    Loading More Posts
    • 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
      qthackerman last edited by

      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 Reply Quote 0
      • First post
        Last post