Bug 157785 - KComboBox's returnPressed signals not working
Summary: KComboBox's returnPressed signals not working
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-13 15:35 UTC by Valerio Pilo
Modified: 2008-02-14 12:26 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Simple kde4 test app (8.52 KB, application/x-gzip)
2008-02-13 18:12 UTC, Valerio Pilo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Valerio Pilo 2008-02-13 15:35:52 UTC
Version:            (using Devel)
Installed from:    Compiled sources
Compiler:          gcc version 4.2.1 (SUSE Linux)
 
OS:                Linux

I am using a KComboBox with popup completion to enter an email address, but also allow to use the popup to choose another email from a predefined list.
I then connected the KComboBox's "returnPressed()" signal to a slot in my class; but when I press the enter/return key, no signal is emitted; there is no debug message in my console output (all debug areas are enabled from kde4's kdebugdialog) and my method isn't called.

That's the same with the returnPressed(const QString &) signal.

However, connecting my slot to the internal QLineEdit works as intended, typing the Enter key calls my slot.

two examples to clarify. This doesn't work:
>  connect( handleCombobox_, SIGNAL(   returnPressed()  ),
>           this,            SLOT  (      updateView()  ) );
The slot is never called and no debug message is output to console.
This does work:
>  connect( handleCombobox_->lineEdit(), SIGNAL(   returnPressed()  ),
>           this,                        SLOT  (      updateView()  ) );

The API clearly states the presence of these signals in KComboBox: http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKComboBox.html
I looked at the source it should emit at least one of these two signals when the KComboBox has a line edit and is enabled, but I have an enabled QLineEdit into the combobox and they are not emitted at press of the enter key.
Comment 1 Anne-Marie Mahfouf 2008-02-13 16:05:21 UTC
The best would be to attach a test case, a minimum program that proves your point.
Comment 2 Valerio Pilo 2008-02-13 18:12:51 UTC
Created attachment 23561 [details]
Simple kde4 test app

There you go. I've put together a quick CMake app which connects the
returnPressed() signals from KComboBox and the internal QLineEdit. Only the
QLineEdit signal though, causes the label to be updated.
Comment 3 Anne-Marie Mahfouf 2008-02-13 20:07:46 UTC
Confirmed, not sure what's wrong in the KComboBox code though...
Comment 4 David Faure 2008-02-13 23:05:22 UTC
OK, I had a look (since I had written a unittest for this) and I found a workaround: 
combo_ = new KComboBox( true, this ) 
makes the combobox work as expected.

So the problem is calling setEditable after creation; I'll check why.
Comment 5 David Faure 2008-02-13 23:37:37 UTC
SVN commit 774759 by dfaure:

Fix KComboBox not emitting returnPressed when it was created with rw=false and setEditable(true) afterwards.
It really sucks that QComboBox::setLineEdit() is not virtual anymore.
BUG: 157785


 M  +19 -3     tests/klineedit_unittest.cpp  
 M  +3 -0      tests/klineedit_unittest.h  
 M  +14 -6     widgets/kcombobox.cpp  
 M  +12 -0     widgets/kcombobox.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=774759
Comment 6 Anne-Marie Mahfouf 2008-02-14 08:49:01 UTC
Thanks for your quick and efficient fix!
Comment 7 Valerio Pilo 2008-02-14 12:26:01 UTC
:o never saw a quicker resolution... thank you very much! You're all doing an awesome work ;)