[Qt-interest] Intercept Esc and Return/Enter keys in a QComboBox line edit
chandrasekar wagmare
sekarwagmare at gmail.com
Thu Mar 12 09:36:22 CET 2009
simple i also crossed this problem ...
this because of using dialog as parent .. use this ..
QAction *quitAction = new QAction(tr(""), this);
quitAction->setShortcut(QKeySequence(Qt::Key_Escape));
connect(quitAction, SIGNAL(triggered()), this, SLOT(goMainPage()));
addAction(quitAction);
QAction *quit2Action = new QAction(tr("E&xit"), this);
quit2Action->setShortcut(tr("Ctrl+Q"));
connect(quit2Action, SIGNAL(triggered()), this, SLOT(askQuit()));
addAction(quit2Action);
or else
reimplement QCloseEvent to certain condition ...
On Tue, Mar 10, 2009 at 8:54 PM, Luper Rouch <luper.rouch at gmail.com> wrote:
> I would like to make a QComboBox that acts like this :
> * if the last item is selected:
> * make the combo box editable,
> * select the text in the combo box line edit then,
> * if the user presses Esc: return the combo box to its initial state
> * if the user presses Return, Enter or the focus leaves the combo
> box:
> * insert the edited text as a new item in the combo box
> * return the combo box to its initial, non editable state
>
> What I have done is almost working, except that when Esc or Return is
> pressed, the key press is also passed to the parent dialog, which closes
> it. How could I "trap" the key press in the line edit while it's being
> edited ?
>
> Thanks,
> Luper
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
CHANDRU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090312/5791d766/attachment.html
More information about the Qt-interest-old
mailing list