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. QML MessageDialog and code after open()
Forum Updated to NodeBB v4.3 + New Features

QML MessageDialog and code after open()

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.2k 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.
  • T Offline
    T Offline
    TonyN
    wrote on last edited by
    #1

    Hi all, I have this scenario, that is not a problem for me right now, but it's baffle me. This is in QML

    I have a 'Window' opened from somewhere else. The main Window will receive a signal from C++ side. In the code that handle the signal, I have a MessageDialog pop up to inform user about the event that the signal is intended for. My goal is closing the opening 'Window' in this code too. But

    1. if I have the Window.close() code after the MessageDialog.open(), the close() never work.
    2. if I have the Window.close() code before the MessageDialog.open(), the close() works fine!!

    I understand that the open(), even as a modal dialog, will not stop the execution, but then it should close the 'Window' even the close() is executed after the open()!

    Can someone explain how QML behave this way?

    p3c0P 1 Reply Last reply
    0
    • T TonyN

      Hi all, I have this scenario, that is not a problem for me right now, but it's baffle me. This is in QML

      I have a 'Window' opened from somewhere else. The main Window will receive a signal from C++ side. In the code that handle the signal, I have a MessageDialog pop up to inform user about the event that the signal is intended for. My goal is closing the opening 'Window' in this code too. But

      1. if I have the Window.close() code after the MessageDialog.open(), the close() never work.
      2. if I have the Window.close() code before the MessageDialog.open(), the close() works fine!!

      I understand that the open(), even as a modal dialog, will not stop the execution, but then it should close the 'Window' even the close() is executed after the open()!

      Can someone explain how QML behave this way?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @TonyN
      As per the doc,

      If the QGuiApplication::quitOnLastWindowClosed property is true, and there are no other windows open, the application will quit.

      So in this case the MessageDialog is still open. Change its modality to Qt.NonModal and see if it works.

      157

      T 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @TonyN
        As per the doc,

        If the QGuiApplication::quitOnLastWindowClosed property is true, and there are no other windows open, the application will quit.

        So in this case the MessageDialog is still open. Change its modality to Qt.NonModal and see if it works.

        T Offline
        T Offline
        TonyN
        wrote on last edited by
        #3

        @p3c0 It indeed works. But then would the users can interact with background while the MessageBox is shown?

        (Btw, the "Window" that I opened is not the main window. It's just another pop up window. However, I learn that it's not the "Window" issue as it still does not work with the ApplicationModal option even I only put console.log() after the MessageBox.open() )

        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