Derek Fountain wrote:
> I have a dialog with a dismiss button, the clicked signal of which is
> linked to the dialog's accept() slot.
> 
> Elsewhere in the dialog I have a QLineEdit that I want the user to be
> able to enter a string into. I give the QLineEdit focus with
> setFocus() at dialog startup time. This works - when the dialog comes
> up the cursor is sat blinking in the QLineEdit and the user can
> immediately edit the contents as expected.
> 
> The problem is that when the user hits the Return key, the Dismiss
> button sees it and the dialog gets dismissed. I'm not sure if the
> keypress is just being grabbed by the Dismiss button or whether it's
> propogating upwards to it. Either way, my question is, what do I need
> to do to ensure the Return key press is acted on by the QLineEdit
> widget, and that widget only?

Dialogs have some extra logic to delegate return presses to what we call 
the default button. QPushButton's have a property called autoDefault 
which means that Qt decides which button is the default. This is 
typically used together with QButtonGroup where you have ok and cancel, 
where autodefault will pick the ok button.

If you disable the autodefault property of your dismiss button, you it 
won't trigger accept anymore.

best regards,
Gunnar
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to