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. QDialog close action on pressing Window 'X'
Forum Updated to NodeBB v4.3 + New Features

QDialog close action on pressing Window 'X'

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 369 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.
  • D Offline
    D Offline
    DeeDee14
    wrote on last edited by
    #1

    Hi,

    Trying to implement a QDialog where on click of 'X' on the window toolbar should show up a QMessageBox with the QDialog in backgroud.

    I initially tried listening to signal QDialog::finish, and on this signal; dynamically created a QMessageBox and also added the attribute WA_DeleteOnClose = false on my QDialog.

    But, when I click on 'X'; the window closes, shows the message box (on accepting the message box; the entire dialog closes and reject; the dialog should stay) --> the QDialog box is not seen in the background.

    I'd like the Qdialog to stay in the background when the QMessageBox opens up.

    Any help?

    JonBJ 1 Reply Last reply
    0
    • D DeeDee14

      Hi,

      Trying to implement a QDialog where on click of 'X' on the window toolbar should show up a QMessageBox with the QDialog in backgroud.

      I initially tried listening to signal QDialog::finish, and on this signal; dynamically created a QMessageBox and also added the attribute WA_DeleteOnClose = false on my QDialog.

      But, when I click on 'X'; the window closes, shows the message box (on accepting the message box; the entire dialog closes and reject; the dialog should stay) --> the QDialog box is not seen in the background.

      I'd like the Qdialog to stay in the background when the QMessageBox opens up.

      Any help?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @DeeDee14
      I have not followed the detail but do you want to show the message box by subclassing QDialog and overriding QDialog::closeEvent(QCloseEvent *e)? See also the example at QWidget::closeEvent(QCloseEvent *event), is that what you are wanting to do?

      D 1 Reply Last reply
      1
      • JonBJ JonB

        @DeeDee14
        I have not followed the detail but do you want to show the message box by subclassing QDialog and overriding QDialog::closeEvent(QCloseEvent *e)? See also the example at QWidget::closeEvent(QCloseEvent *event), is that what you are wanting to do?

        D Offline
        D Offline
        DeeDee14
        wrote on last edited by
        #3

        @JonB Trying to implement something like this:
        ed09165a-d903-4ae7-8a95-006dfe7348d6-image.png

        Where on click of 'X'; the message box shows up and on click of cancel on messageBox, I remain on QDialog.

        Currently, on click of 'X' - the Dialog closes; shows the message box. And on clicking cancel on the messageBox; the dialogs shows again.

        This is how I tried implementing it:

        dialog->setAttribute(Qt::WA_DeleteOnClose, false);
        QObject::connect(dialog, SIGNAL(finished), this, [this](){
        // create a message box
        });
        
        JonBJ 1 Reply Last reply
        0
        • D DeeDee14

          @JonB Trying to implement something like this:
          ed09165a-d903-4ae7-8a95-006dfe7348d6-image.png

          Where on click of 'X'; the message box shows up and on click of cancel on messageBox, I remain on QDialog.

          Currently, on click of 'X' - the Dialog closes; shows the message box. And on clicking cancel on the messageBox; the dialogs shows again.

          This is how I tried implementing it:

          dialog->setAttribute(Qt::WA_DeleteOnClose, false);
          QObject::connect(dialog, SIGNAL(finished), this, [this](){
          // create a message box
          });
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @DeeDee14
          Which is what the references I gave you cover.

          D 1 Reply Last reply
          1
          • JonBJ JonB

            @DeeDee14
            Which is what the references I gave you cover.

            D Offline
            D Offline
            DeeDee14
            wrote on last edited by
            #5

            @JonB Got it, let me try that. Thank you!

            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