[Interest] Whole edit window closes.

Benjamin TERRIER b.terrier at gmail.com
Wed Mar 13 12:06:16 CET 2019


Le mar. 12 mars 2019 à 21:39, Bill Crocker
<william.crocker at analog.com> a écrit :
>
> Hello:
>
> Sorry. A boring old desktop widget problem...
>
> I have a QTableView.
> I use a QStyledItemDelegate on each cell.
> The delegate opens a custom, modal editor on double click.
> The editor is based on a QDialog and contains a number of widgets,
> one of which is a QComboBox.
> When I press <Return> in the text entry area of the QComboBox,
> the whole edit window closes, but I am not done "editing". Arg.
>
> (Most of the time that is what you want because the QComboBox is
>   the only widget in the editor, but not here.)
>
> I have tried a number of things related to focus, default buttons
> but nothing has worked.
>
> How do I keep the editor open
> until I press the OK button.
>
> Thanks.
>
> Bill
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest

Hi,
I had this kind of issue back in the Qt 4.8 days

>From what I remember, the issue is that the QComboBox does not consume
the "return pressed" event.
So the event propagates to the QDialog which handles the event by
"pressing" the default button and closing itself.
The only solution I found was to filter the "return pressed" event,
using an event filter (`QObject::installEventFilter()`)
so that it does not reach the QDialog.

BR,

Benjamin


More information about the Interest mailing list