[PyKDE] modal dialog SLOT problem

Dave S eric3 at pusspaws.net
Tue Oct 10 18:22:51 BST 2006


On Tuesday 10 October 2006 14:58, Andreas Pakulat wrote:
> On 09.10.06 23:00:35, Dave S wrote:
> > On Monday 09 October 2006 20:41, Andreas Pakulat wrote:
> > > create a subclass from QDialog and the form and implement 3 slots,
> > > connect each slot to one of the buttons. Then in each slot set a member
> > > variable of self to 0, 1 or 2 and then call accept or reject
> > > accordingly.
> > >
> > > After dialog_instance.exec_() returned you can check the member
> > > variable of dialog_instance to know which button was pressed.
> >
> > Thank you for replying :)
> >
> > I hear what you are saying and on designer QT3 this works very well.
> >
> > Unfortunately I did not explain myself very well. I am using designer QT4
> > which has done away with the option of creating slots inside the
> > generated dialogue ... thus my problem !
>
> You don't need slots created by designer. Just write a python class that
> subclasses from QDialog and you Ui. See the PyQt4 examples for some
> inspiration.

Got ya :) - so you mean a subclass something like

def reset(self):
	self.key_press = 'reset'
....

and connect so and so reset button to reset() ... which I know how to do 
already; using the result from self.key_press :)

> In that subclass you then have the slots (you could even use 
> auto-connection for that) which sets the member variable.

Yes I have used auto connect already for my main window

>
> > > I don't think your idea can work, because your slot is executed after
> > > exec_() has finished.
> >
> > Execution of ...
> > print justify_dialog.exec_()
> > continues indefinitely,
> >
> > I was hoping that
> > QtCore.QObject.connect(justify_dialog.pushButton_3,QtCore.SIGNAL("clicked
> >()"),justify_dialog,QtCore.SLOT("done(2)")) would call widget.done(2)
> > which exits the dialog and justify_dialog.exec_() returning a 2. Although
> > since it does not work I am more than happy to stand corrected.
>
> This should print a message on the terminal, as the connection cannot be
> made. You cannot give argument values to slots when connecting them to
> signals.

Ahh I was starting to wonder this - thank you for confirming it ...


>
> Andreas

Andreas thank you very much. I will go and code :)

Cheers

Dave




More information about the PyQt mailing list