14

I looked into the documentation and i found 'self.setWindowModality(QtCore.Qt.WindowModal)'.
I added this function to my 'init' function, but however still was not able to create a modal dialog box.

Any help will be appreciated,
Thank You.

user3135832
  • 191
  • 1
  • 1
  • 8

1 Answers1

29

QDialog has setModal() as found here.

As the docs state:

By default, this property is False and show() pops up the dialog as modeless. Setting this property to true is equivalent to setting QWidget.windowModality to Qt.ApplicationModal.

As @sebastian noted you could use exec(). However it is better to use exec_() as the one sebastian mentioned is also a python call.

Example:

my_dialog = QDialog(self) 
my_dialog.exec_()  # blocks all other windows until this window is closed.

If this doesn't help please post your code and I will have a look.

Shadow9043
  • 2,140
  • 1
  • 15
  • 13
  • 1
    Sorry for wasting your time. I realised that what i was looking for was a system modal dialog, i should have read the docs properly. I'll edit the question. I apologise, but do you know if it is possible to create a system modal dialog in ppyqt for linux. Thanks. – user3135832 Jul 12 '14 at 10:03
  • By System Modal you mean that your window should be on top of every other applications window? This is generally a bad idea and will end up frustrating your end user(s). – Shadow9043 Jul 12 '14 at 11:18
  • 1
    Its actually a license agreement for a linux distro. – user3135832 Jul 12 '14 at 12:17
  • 1
    FWIW: I of course meant to use `exec_`, I just happen to use the Qt reference usually. Since `exec` not only a python call but a keyword - the `exec` method can't exist in python anyway. – sebastian Jul 14 '14 at 07:14
  • how to show a dialog blocks only some windows rather than the entire application? – bactone Sep 02 '21 at 09:26