[PyKDE] modal dialog SLOT problem
Dave S
eric3 at pusspaws.net
Mon Oct 9 23:00:35 BST 2006
On Monday 09 October 2006 20:41, Andreas Pakulat wrote:
> On 09.10.06 20:20:22, Dave S wrote:
> > I have aQT4 modal dialog and I need to know which of the three buttons
> > have been pressed. accept() & reject() are OK for two buttons giving me 0
> > & 1.
> >
> > For the third I googled & read and thought of ...
> >
> >
> > justify_dialog = QtGui.QDialog(self)
> > os.chdir(self.config.get('paths','dialogs')) # Use
> > 'os.chdir' else ui PNGs are lost
> > uic.loadUi('justify.ui', justify_dialog)
> >
> > I know I am on the right track because
>
> IMHO not really.
>
> Try this:
>
> 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 !
>
> 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.
Dave
>
> Andreas
More information about the PyQt
mailing list