0

A MessageBox in PyQt will not acces the parent window... I tried implementing the custom messageBox. But nothing worked for me.

I tried with QWidget but with Qwidget the widgets are placing on the mainWindow itself like below image

widget in mainWindow

Then I implemented the dialog box and it worked fine but the issue is we can also access the main window when the dialog box is opened. I want it be like mainWindow can't be accessed when dialog box is opened.

class MainClass(QtGui.QDialog):
  def __init__(self, parent=None):
    super(MainClass, self).__init__(parent)
    self.setParent(parent)

    #widgets added below
    ...

Can anyone help with this?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

I don't know if i understood your question right, but if your problem is just that your dialog does not block input to other visible windows in the same application, then the solution is to setModal(True).

You can do it as embryo said with exec_ instead of show, or setModal by hand.

class MainClass(QtGui.QDialog):
    def __init__(self, parent=None):
        super(MainClass, self).__init__(parent)
        self.setParent(parent)
        self.setModal(True)
        #widgets added below

There is a similar Question here: How to create a modal window in pyqt?

Easy_Israel
  • 841
  • 6
  • 8