Solved QComboBox popup menu
-
Curious, has anyone ever created their own ComboBox class inherited from QComboBox where you can emit a signal when the popmenu has been clicked and, of course, emit a signal once it is closed? It's just when the popup menu is clicked, the main ComboBox loses focus. I'm trying to capture the event of the popup, but I've never really worked with Event Filtering in QT. Any help would be most appreciated.
-
No need for event filtering just reimplement
showPopup
andhidePopup
#ifndef TESTCOMBO_H #define TESTCOMBO_H #include <QComboBox> class TestCombo : public QComboBox { Q_OBJECT public: TestCombo(QWidget* parent=nullptr):QComboBox(parent){} virtual ~TestCombo()=default; virtual void hidePopup() override{ emit menuHidden(); QComboBox::hidePopup(); } virtual void showPopup() override{ emit menuPopped(); QComboBox::showPopup(); } signals: void menuPopped(); void menuHidden(); }; #endif // TESTCOMBO_H
-
@VRonin Thank you so much! This is exactly what I was looking for. I appreciate your help!