[PyKDE] modal dialog SLOT problem

Andreas Pakulat apaku at gmx.de
Tue Oct 10 14:58:38 BST 2006


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. In that subclass you then have the slots (you could even use
auto-connection for that) which sets the member variable.

> > 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.

Andreas

-- 
You will hear good news from one you thought unfriendly to you.




More information about the PyQt mailing list