Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:11:37+00:00 2026-06-11T19:11:37+00:00

I have a QDialog object. When the user clicks on the X button or

  • 0

I have a QDialog object. When the user clicks on the X button or presses Ctrl+Q, I want the dialog to go to a minimized view or system tray icon, instead of closing. How do I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:11:39+00:00Added an answer on June 11, 2026 at 7:11 pm

    A simple subclass that minimizes instead of closing is the following:

    class MyDialog(QtGui.QDialog):
        # ...
        def __init__(self, parent=None):
            super(MyDialog, self).__init__(parent)
    
            # when you want to destroy the dialog set this to True
            self._want_to_close = False
    
        def closeEvent(self, evnt):
            if self._want_to_close:
                super(MyDialog, self).closeEvent(evnt)
            else:
                evnt.ignore()
                self.setWindowState(QtCore.Qt.WindowMinimized)
    

    You can test it with this snippet in the interactive interpreter:

    >>> from PyQt4 import QtCore, QtGui
    >>> app = QtGui.QApplication([])
    >>> win = MyDialog()
    >>> win.show()
    >>> app.exec_()   #after this try to close the dialog, it wont close bu minimize
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dialog with a big textbox. I want the user to be
I have a QDialog with a QDialogButtonBox widget, and I've connected the button box's
I want to create a login dialog by inheriting QDialog. I put in subclass
I have a main dialog and on that dialog there is a button. When
I have a QDialog which I open like this: void MyModule::openDialog() { this->dialog->open(); printf(Hello
I have a QDialog inside which I want to display 50 QComboBoxes in a
So I have a frameless QDialog that I want to be able to move
I have a dialog with LineEdit elements. I want the dialog to close if
I have a dialog inherits QDialog. the dialog has many widgets including Qbuttons, QLabel,
I have a modal QDialog, that on the click of a button slides a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.