#ifndef QMYCOMBOBOX_H #define QMYCOMBOBOX_H #include #include class QMyComboBox : public QComboBox { public: QMyComboBox(QWidget* parent = nullptr) : QComboBox(parent) , m_workaround_showing(false) {} ~QMyComboBox() {} protected: void showPopup() override { m_workaround_showing = true; QComboBox::showPopup(); m_workaround_showing = false; } void hidePopup() override { if(!m_workaround_showing) { QComboBox::hidePopup(); } } //Alternative solution, ignore the mouse release //bool eventFilter(QObject *obj, QEvent *event) override { // if((obj == view()->window()) && // (event->type() == QEvent::MouseButtonRelease) && // m_workaround_showing) { // return true; // } // return QComboBox::eventFilter(obj, event); //} private: m_workaround_showing: }; #endif // QMYCOMBOBOX_H