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. Qt window automatically closes the window when clicking outside the window area
Qt 6.11 is out! See what's new in the release blog

Qt window automatically closes the window when clicking outside the window area

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.6k 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.
  • J Offline
    J Offline
    Jun_
    wrote on last edited by
    #1

    I have a button that needs to show or hide a window. At the same time, when the window is displayed, clicking anywhere outside the window needs to hide the window. How can I achieve this in qml?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jun_
      wrote on last edited by Jun_
      #2

      I used the activefocusitemchanged signal and closed the window in the signal, but at this time if I click the button, it will trigger the opening again, which should have been closed.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bob64
        wrote on last edited by
        #3

        What sort of "window" is it? The sort of behaviour you want is supported by Popup. See closePolicy property.

        J 1 Reply Last reply
        0
        • B Bob64

          What sort of "window" is it? The sort of behaviour you want is supported by Popup. See closePolicy property.

          J Offline
          J Offline
          Jun_
          wrote on last edited by
          #4

          @Bob64

          Thanks for your reply.

          Not only does the closing strategy require the mouse to click outside to disappear, but also a button to control closing and showing. Clicking on the button triggers the closing strategy at the same time, which will cause the window to close and then open again.

          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