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. Change the reject or close event in Qdialog

Change the reject or close event in Qdialog

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.3k Views 2 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.
  • S Offline
    S Offline
    SujaMM
    wrote on last edited by
    #1

    Hello,

    I need to change the reject or close event in a QDialog, I need to hide the Qdialog when the X button on the frame it's press, but to close the window when the reject or close method it's call in the window.

    Can someone give me some inside in to how to do this or any other idea to this ??

    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by alex_malyu
      #2

      When X button is clicked it is normal behavior that QDialog is hidden.
      "reject or close method it's call in the window." - does not make sense.

      It is not clear what you want to do.
      This is not an offense but to give any advice people need to understand what you want to achieve.

      What happens in QWidget derived classes is defined in
      void QWidget::closeEvent(QCloseEvent *event)

      You can override it in your class to control what happens like below:
      void MainWindow::closeEvent(QCloseEvent *event)
      {
      if (maybeSave()) {
      writeSettings();
      event->accept();
      } else {
      event->ignore();
      }
      }

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SujaMM
        wrote on last edited by
        #3

        I'm sorry If I didn't explain myself, but when I push the X button of the QDialog the QDialog closes and the application too.

        What I need it's to close the QDialog only when I call the reject() or accept() method in my code and to hide the QDialog in the trayIcon when the X button it's press.

        I don't know how to explain this better.

        p3c0P 1 Reply Last reply
        0
        • S SujaMM

          I'm sorry If I didn't explain myself, but when I push the X button of the QDialog the QDialog closes and the application too.

          What I need it's to close the QDialog only when I call the reject() or accept() method in my code and to hide the QDialog in the trayIcon when the X button it's press.

          I don't know how to explain this better.

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

          @SujaMM As @alex_malyu explained you need to override closeEvent to handle operation when close button is clicked.
          To minimize it to tray, use QSystemTrayIcon. Check out the example here.

          157

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SujaMM
            wrote on last edited by
            #5

            Thanks for the help I have solve this problem, now I'm having a different problem with the SystemTrayIcon. I'm going to post another topic to see who can help me.

            Thanks for everything 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