[PyQt] stuck on non-modal dialog

Hans-Peter Jansen hpj at urpla.net
Wed May 23 20:26:05 BST 2007


Am Mittwoch, 23. Mai 2007 16:26 schrieb Phil Thompson:
> On Wednesday 23 May 2007 3:18 pm, David J Brooks wrote:
> > On Wednesday 23 May 2007 02:22:41 am Phil Thompson wrote:
> > > On Wednesday 23 May 2007 2:20 am, David J Brooks wrote:
> > > > I'm sure I must be overlooking something obvious, but I don't see
> > > > it.
> > > >
> > > > Ive set up a main window for MDI and added a Find dialog, with
> > > > signals and slots to activate it. The dialog pops up as expected,
> > > > but is totally unresponsive. Nothing typing into its lineEdit does
> > > > nothing, buttons don't seem to 'click'  etc. Worse, it seems to
> > > > hang the application, requiring a killall -9 python to close it.
> > > > What am I not seeing?
> > > >
> > > > class MainWindow(QtGui.QMainWindow):
> > > >     def __init__(self, fileName=None, parent=None):
> > > >         QtGui.QMainWindow.__init__(self, parent)
> > > >         self.ui=Ui_MainWindow()
> > > >         self.ui.setupUi(self)
> > > >         self.workspace=QtGui.QWorkspace(self)
> > > >         self.setCentralWidget(self.workspace)
> > > >         self.finder=findDialog()
> > > >         self.connect(self.ui.actionFind,
> > > > QtCore.SIGNAL("triggered()"), self.findWord)
> > > >
> > > >     def findWord(self):
> > > >         self.finder.show()
> > > >         self.workspace.setActiveWindow(self.finder)
> > > >
> > > >
> > > > class findDialog(QtGui.QDialog):
> > > >     def __init__(self, parent=None):
> > > >         QtGui.QDialog.__init__(self, parent)
> > > >         self.ui=Ui_findDialog()
> > > >         self.ui.setupUi(self)
> > > >         self.setModal=(False)
> > >
> > > You might want to look at the line above.
> >
> > I'm looking, but I'm not sure what I'm meant to see. setModal(False)
> > shouldn't do anything at all, because the dialog should be non-modal by
> > default.
>
> That's not what the line says.
>
> > Removing the line in question does not make the dialog responsive.
> > Setting it to True (and changing the show method to exec_) provides a
> > responsive modal dialog that still does not return control back to the
> > application.
>
> I'm not saying that that line is the cause of the problem, just that (as
> posted) it is wrong.

You're overwriting the class method with a tuple. That cannot do, what 
you're expecting..

Phil sparse answers are legendary, he approaching a S/N ratio near 100%.

BTW, if such simple things nowadays doesn't work as expected with this 
toolkit, the problem most likely locates between keyboard and chair. Using 
a snapshot release doesn't change this fact significantly. OTOH, you will 
find yourself building on this fact pretty soon.

Good luck,
  Pete


More information about the PyQt mailing list