Search code examples
qtpyqtdestroyqdialog

Qt4 Differences between close and destroy?


When i type the command destroy() for a dialog (I haven't tried another types of windows) Qt retuns this message:

X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Extension:    130 (MIT-SHM)
  Minor opcode: 3 (X_ShmPutImage)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Extension:    130 (MIT-SHM)
  Minor opcode: 3 (X_ShmPutImage)
  Resource id:  0x0

But if i type 'close()' it works correct.

So what's the differences between close() and destroy()? Or is there any difference?


Solution

  • You should not use destroy() if you don't have a good reason. It is supposed to be part of the destruction, e.g. it is called internally for clean-up. The error messages indicate that during destroy, X window resources are free'd that are still referenced. So they are free'd prematurely.

    The method close() on the other hand is the proper way to signal that a window/dialog should be closed. It is doing the same as if the user would request a window to close (e.g. clicking on the close button on the window frame title).