QComboBox: issue when used with eventFilter
-
I need to implement a QComboBox like widget that, when open, displays a list of checkable items. I would like the user to be able to check/uncheck more than one item before the QComboBox closes. I'm working with Qt 5.4.
To that end, I subclassed QComboBox reimplementing eventFilter() that is attached to the QComboBox's view and to its viewport. This eventFilter() method aims at intercepting MousButtonRelease and FocusOut events so that hidePopup() is not invoked on MouseButtonRelease but rather on FocusOut event.
This does not work. Actually, the eventFilter does not receive any event after showPopup is called and before hidePopup is except one: A FocusAboutToChange event which is received right after showPopup, when the QComboBoxListView is displayed.
What is happening? What did I do wrong? I had a look at the QComboBox code and it also installs an eventFilter on both the view and its view port, intercepting the same events. As far as I saw, I install my eventFilter after QComboBox's. The doc says that mine should be called first.
Is there a better way to do this?I also read a few posts on QComboBox, "this one":http://qt-project.org/faq/answer/how_can_i_make_a_qcombobox_have_multiple_selection for instance. But this did not help for the purpose...
Thanks a lot!
-
Hi and welcome to devnet,
You might be interested by "QxtCheckComboBox":http://libqxt.bitbucket.org/doc/0.6/qxtcheckcombobox.html
Hope it helps