[PyQt] Problems with QDialog, QLineEdit and returnPressed event

duncan duncan duncan73 at gmail.com
Wed Oct 10 13:02:29 BST 2007


I am trying to have a QDialog (the gui was designed with QtDesigner) with
some QLineEdit widget.
The QLineEdit widget is connected to the returnPressed event.

All work fine but when I press the Return key the dialog close.
At this point find that the buttons on the dialog need to have the
autoDefault property set to False.

The dialog has a QDialogButtonBox for the two buttons (Ok and Cancel), and
these buttons still have the
autoDefault property set to True but I am not able to set it to False.

I try with QtDesigner but all I see is the QDialogButtonBox widget, no
access to the buttons, so I try with this code:

for btn in self.uid.buttonBox.buttons():

and this fail too.

How can I solve the problem ? For now I have a workaround: I delete the
QDialogButtonBox and use just to buttons
connected with the accept() and reject() signal and this work.

As a side note: I understand it correctly that if I need some input
(QLineEdit specifically) connected wiht the returnPressed signal
it is better to create a void dialog and then put all the controls than to
create a dialog with the standard buttons ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071010/9205e878/attachment.html

More information about the PyQt mailing list